Trên trang này

Trang này chưa có bản tiếng Việt, nội dung bên dưới là bản tiếng Anh. Xem trang tiếng Anh

Carousel

When to use a carousel, how it moves, content and tokens.

Draft. Ported from the shadcn-vue Carousel and restyled with Beehexa tokens. Not yet approved; the API may still change.

A carousel shows a row of slides, one or a few at a time. People move through them with the Previous and Next buttons, by swiping, or with the arrow keys.

When to use

  • A short set of things people browse, not read in full: getting-started tips, featured products, screenshots.
  • When the slides are equal, and missing some is fine.

When not to use

  • For anything people must see. Most people never move past the first slide. Put important content on the page.
  • For a long list. Use a grid or a Table people can scan and search.
  • For steps people must follow in order. Use a stepper or a wizard.
  • To rotate content on its own. Don’t turn on autoplay; if a product needs it, give a pause button and stop on hover and focus (WCAG 2.2.2).

Behaviour

  • Previous and Next sit outside the slides, 48 px from the edge; leave room for them (px-12 on the container) or move them with class.
  • At either end the button is disabled, in the disabled colours.
  • Click or Tab to the carousel, then use ← and → (↑ and ↓ when vertical).
  • Several slides in view: set the item basis (basis-1/3) and :opts="{ align: 'start' }".

Content

  • Name the carousel: aria-label="Getting started tips".
  • Name each slide with its position: “2 of 5”.
  • Three to seven slides. Fewer fit on the page; more are not seen.

Tokens

Part Tokens
Slide gap space.200
Buttons Default (outline) icon button, size="icon-sm" (size.control.small), radius.pill
Focus border.width.focused, color.border.focus, state.focus.offset on the carousel and the buttons
Slides Your content; cards use the Card tokens