ScrollRail
A horizontal strip of cards that scrolls instead of wrapping.
itemWidth, header and equal-height cards
Reflections worth sitting with.
In context
Good morning, Maya
Harbour launch is on 24 Oct. Pick up where you left off.
Props
| Prop | Type | Required | Default |
|---|---|---|---|
children | ReactNode | Yes | — |
aria-label | string | Yes | — |
controls | boolean | undefined | No | true |
snap | boolean | undefined | No | — |
autoScroll | number | boolean | undefined | No | — |
loop | boolean | undefined | No | false |
gap | "sm" | "md" | "lg" | (string & {}) | undefined | No | md |
itemWidth | string | number | { base: string | number; md?: string | number | undefined; } | undefined | No | — |
header | ReactNode | No | — |
Accessibility
Root is role="region" named by the required aria-label (deliberately not aria-roledescription="carousel"); the track is a role="list" and each item a role="listitem". The viewport is focusable so the arrow keys scroll it from the keyboard. Prev/next buttons disable at either end.
Auto-scroll pauses while the pointer is over or pressing the viewport, while focus is inside it, and while the tab is hidden; it never runs under prefers-reduced-motion (the rail becomes a normal manual rail with prev/next). Whenever auto-scroll is active a visible Pause/Play button is rendered (WCAG 2.2.2), and the prev/next buttons are hidden. With loop, the duplicated items are aria-hidden and inert, so assistive tech and Tab never see them.
data-rebar-* attributes
data-rebar-component="scroll-rail" on the root, with data-rebar-state (static, scrolling or paused), data-rebar-gap (custom for a CSS-length gap), data-rebar-item-width (set with itemWidth), data-rebar-snap, data-rebar-can-scroll-start and data-rebar-can-scroll-end. data-rebar-part values header, header-controls, viewport, track, item, control (prev/next, with data-rebar-direction) and toggle (Pause/Play).
Migrating to Ant Design
Not codemod-covered. Ant Design has no direct equivalent; the nearest idiom is a Flex with overflow-x: auto or a Carousel with slidesToShow, so this is a structural rewrite at migration time.