Data display
CardScroll
A horizontally scrolling list of cards with snapping, optional gutters and arrows that move by one card. Built on HorizontalScroll.
import { CardScroll } from "datui";Examples
Sizes
size sets each card's width; false keeps the card's own width.
Gutters
padding adds space before the first and after the last card.
Accessibility
- Renders a
<ul>; every child becomes an<li>, so screen readers announce the number of cards. - Native scrolling and snapping; the viewport is focusable while it overflows so arrow keys scroll it.
- Arrow buttons are
aria-hiddenand out of the tab order; interactive cards stay reachable with Tab.
API
CardScroll
Horizontally scrolling row of cards rendered as a list. Each child becomes a list item, cards snap to the start edge and arrows move by one card.
| Prop | Type | Default | Description |
|---|---|---|---|
| arrowOffsetX | string | number | — | Distance of the arrows from the inline edges (CSS length or px). |
| arrowOffsetY | string | number | — | Vertical shift of the arrows from the center (CSS length or px). |
| arrowSize | "s" | "m" | "m" | |
| className | string | — | |
| contentClassName | string | — | |
| padding | boolean | false | Adds inline gutters before the first and after the last card. |
| scrollOnAnyWheel | boolean | false | Map vertical mouse-wheel movement to horizontal scrolling. Shift+wheel always works natively. |
| showArrows | boolean | "always" | true | `true` shows arrows on devices with a fine pointer, `"always"` on every device. |
| size | false | "s" | "m" | "l" | s | Width of each card. `false` keeps each card's own width. |
| viewportClassName | string | — | Classes for the scrolling viewport element. |
| viewportRef | Ref<HTMLDivElement> | — | Ref to the scrolling viewport element. |