Carousel
Slides that move left and right, one or a few at a time.
Left out of Dense data Slides hide items, and most people never reach the later ones. Dense data's experts want many records on one screen. Use instead: Table, Card
See it live
npm run storybookWhen to use it
- Use it when: A few images or items people browse for pleasure, where missing some is fine.
- Not when: Content people must see: most never reach the later slides.
Instead:
- Card: A grid shows every item at once.
Words
- Lead with the object, then the state: "Alert 2041 contained."
- Use numbers, not words for numbers.
- One verb per button. No "please", no exclamation marks.
- Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Deletecontent.action.retry: Retrycontent.action.empty-action: Change filters
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Arrow keys move between slides when the carousel has focus. | undefined |
Test before you ship:
- Previous and next are buttons with names; nothing moves on its own without a pause control. undefined
Use it in code
npx open-ds add carousel
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Carousel reads 6 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Carousel's tokens to change Carousel alone.
Dense data decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Item | ||
| Padding left | component.carousel.item.padding-leftcomponent-spacing-map.x4var(--carousel-item-padding-left) | space.16:1rem |
| Padding, top | component.carousel.item.padding-topcomponent-spacing-map.x4var(--carousel-item-padding-top) | space.16:1rem |
| Previous | ||
| Size | component.carousel.previous.sizesize.control.defaultvar(--carousel-previous-size) | size.32:2rem |
| Corner | component.carousel.previous.radiusradius.roundvar(--carousel-previous-radius) | radius.full:9999px |
| Next | ||
| Size | component.carousel.next.sizesize.control.defaultvar(--carousel-next-size) | size.32:2rem |
| Corner | component.carousel.next.radiusradius.roundvar(--carousel-next-radius) | radius.full:9999px |