Skip to content
All components
Data display

Carousel

Let people browse a short sequence of related slides in a fixed space, moving through them with explicit previous and next controls or a swipe.

A slider built on Embla, horizontal or vertical.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add carousel

Then import it from @/components/ui/carousel. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Multiple visible

Show several slides per view and fewer on narrow screens. Slide basis classes change by breakpoint; the next slide stays partly visible as a cue that more content exists. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel"

const articles = [
  { title: "Planning a quarterly review", minutes: 6 },
  { title: "Writing release notes people read", minutes: 4 },
  { title: "Running a calm incident call", minutes: 8 },
  { title: "Onboarding in the first week", minutes: 5 },
  { title: "Choosing metrics that matter", minutes: 7 },
  { title: "Keeping meetings short", minutes: 3 },
]

export function CarouselMultipleVisible() {
  return (
    <div className="flex w-full max-w-2xl flex-col items-center gap-16 px-12">
      <Carousel opts={{ align: "start" }} aria-label="Recommended articles" className="w-full">
        <CarouselContent>
          {articles.map((article, index) => (
            <CarouselItem
              key={article.title}
              aria-label={`${index + 1} of ${articles.length}`}
              className="basis-4/5 sm:basis-1/2 lg:basis-1/3"
            >
              <a
                href={`#article-${index + 1}`}
                className="flex h-36 flex-col justify-between rounded-16 border border-soft-200 p-4 outline-none focus-visible:outline-2 focus-visible:outline-primary-base focus-visible:outline-solid"
              >
                <span className="text-label-sm text-strong-950">{article.title}</span>
                <span className="text-paragraph-sm text-sub-600">{article.minutes} min read</span>
              </a>
            </CarouselItem>
          ))}
        </CarouselContent>
        <CarouselPrevious />
        <CarouselNext />
      </Carousel>
    </div>
  )
}

Slide counter

Show the current position with a polite slide counter. setApi exposes the Embla API so the parent can read the selected snap and announce changes. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
  type CarouselApi,
} from "@/components/ui/carousel"

const steps = [
  { title: "Create a workspace", body: "Name it after your team or project." },
  { title: "Invite teammates", body: "Send invitations by email or share a link." },
  { title: "Add your first project", body: "Projects hold documents, tasks and files." },
  { title: "Pick notification settings", body: "Choose what reaches you and when." },
]

function SlideCounterCarousel() {
  const [api, setApi] = React.useState<CarouselApi>()
  const [current, setCurrent] = React.useState(1)
  const [count, setCount] = React.useState(steps.length)

  React.useEffect(() => {
    if (!api) return
    const update = () => {
      setCount(api.scrollSnapList().length)
      setCurrent(api.selectedScrollSnap() + 1)
    }
    update()
    api.on("select", update).on("reInit", update)
    return () => {
      api.off("select", update).off("reInit", update)
    }
  }, [api])

  return (
    <div className="flex w-full max-w-xs flex-col items-center gap-3">
      <Carousel setApi={setApi} aria-label="Getting started steps" className="w-full">
        <CarouselContent>
          {steps.map((step, index) => (
            <CarouselItem key={step.title} aria-label={`${index + 1} of ${steps.length}`}>
              <div className="flex h-40 flex-col justify-center gap-1 rounded-16 border border-soft-200 bg-weak-50 p-5">
                <p className="text-label-md text-strong-950">{step.title}</p>
                <p className="text-paragraph-sm text-sub-600">{step.body}</p>
              </div>
            </CarouselItem>
          ))}
        </CarouselContent>
        <CarouselPrevious />
        <CarouselNext />
      </Carousel>
      <p aria-live="polite" className="text-paragraph-sm text-sub-600">
        Step {current} of {count}
      </p>
    </div>
  )
}

export function CarouselSlideCounter() {
  return (
    <div className="flex w-full max-w-2xl flex-col items-center gap-16 px-12">
      <SlideCounterCarousel />
    </div>
  )
}

Looping

Wrap from the last slide to the first with the loop option. Both arrow buttons stay enabled because there is no boundary. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel"

export function CarouselLooping() {
  return (
    <div className="flex w-full max-w-2xl flex-col items-center gap-16 px-12">
      <Carousel opts={{ loop: true }} aria-label="Customer quotes" className="w-full max-w-xs">
        <CarouselContent>
          {[
            "Setup took an afternoon, not a sprint.",
            "Our weekly report now writes itself.",
            "The team finally uses one calendar.",
          ].map((quote, index) => (
            <CarouselItem key={quote} aria-label={`${index + 1} of 3`}>
              <blockquote className="flex h-32 items-center rounded-16 border border-soft-200 p-5 text-paragraph-md text-strong-950">
                {quote}
              </blockquote>
            </CarouselItem>
          ))}
        </CarouselContent>
        <CarouselPrevious />
        <CarouselNext />
      </Carousel>
    </div>
  )
}

Vertical orientation

Scroll slides vertically inside a fixed height. The arrow buttons rotate and move above and below the viewport, so the layout reserves space for them. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel"

export function CarouselVerticalOrientation() {
  return (
    <div className="flex w-full max-w-2xl flex-col items-center gap-16 px-12">
      <div className="py-12">
        <Carousel
          orientation="vertical"
          opts={{ align: "start" }}
          aria-label="Upcoming events"
          className="w-full max-w-xs"
        >
          <CarouselContent className="h-56">
            {["Design review", "Quarterly planning", "Team retrospective", "Customer interviews", "Release party"].map((event, index) => (
              <CarouselItem key={event} aria-label={`${index + 1} of 5`} className="basis-1/2">
                <div className="flex h-full items-center rounded-12 border border-soft-200 p-4 text-label-sm text-strong-950">
                  {event}
                </div>
              </CarouselItem>
            ))}
          </CarouselContent>
          <CarouselPrevious />
          <CarouselNext />
        </Carousel>
      </div>
    </div>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

Carousel

Present a browsable sequence of slides using Embla.

Carousel props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
orientation"horizontal" | "vertical" | undefined"horizontal"Horizontal or vertical layout. The consuming layout must provide enough space for the selected orientation.
optsPartial<import("embla-carousel").OptionsType> | undefined—Options passed to Embla Carousel. Align scrolling, looping and direction with the surrounding controls.
pluginsimport("embla-carousel").CreatePluginType<import("embla-carousel").LoosePluginType, {}>[] | undefined—Embla plugins installed on this carousel. Consumers own plugin configuration and reduced-motion behavior.
setApi((api: CarouselApi) => void) | undefined—Receive the Embla API after initialization. Use it for consumer-owned controls and lifecycle subscriptions.
Inherited props (13)
Carousel inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

CarouselContent

Content region within the root composition. Keep required providers, labels and related controls from the complete example.

CarouselContent props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
CarouselContent inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

CarouselItem

One item within its parent composition. Keep parent context and the value, label or state required by the source API.

CarouselItem props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
CarouselItem inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

CarouselNext

The CarouselNext part of carousel. Use it with the complete source composition and preserve its required parent context.

CarouselNext props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
intent"primary" | "neutral" | "error" | null | undefined—Semantic purpose: primary action, neutral action, or destructive/error action. Independent of visual emphasis. Defaults to primary.
emphasis"link" | "filled" | "stroke" | "lighter" | "ghost" | null | undefined—Visual weight: filled, stroke, lighter, ghost, or link (text only, underlined on hover). Does not change the action's semantics; use asChild with an anchor when it navigates. Defaults to filled.
size"xs" | "sm" | "md" | "lg" | null | undefined—Control size: xs, sm, md, or lg. Keep labels and icons readable when choosing a size. Defaults to md.
asChildboolean | undefined—Merge styles and behavior into one child element instead of rendering a button. Use a real anchor with href for navigation; native disabled does not disable an anchor. Defaults to false.
iconOnlyboolean | undefined—Square button for a single icon at the selected size. Always provide aria-label (or aria-labelledby) because there is no visible text. Defaults to false.
loadingboolean | undefined—Show a spinner while an operation runs. The button keeps its width and focus, exposes aria-busy and aria-disabled, and ignores activation until loading ends; with asChild the spinner renders inside the child and its onClick and navigation are blocked. Defaults to false.
Inherited props (18)
CarouselNext inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLButtonElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
disabledboolean | undefined—Make the supported control unavailable through its native or primitive disabled semantics. This does not disable arbitrary child links.
formstring | undefined—ID of the form associated with this control, including when it is rendered outside that form element.
namestring | undefined—Name used by the control's form submission or primitive form integration.
type"button" | "submit" | "reset" | undefined—Native element or primitive mode defined by the source union. Choose a supported value; its meaning depends on the component.
valuestring | number | readonly string[] | undefined—Current value in the shape defined by the source type. For controlled interactive inputs, apply updates from the change callback.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLButtonElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLButtonElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLButtonElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

CarouselPrevious

The CarouselPrevious part of carousel. Use it with the complete source composition and preserve its required parent context.

CarouselPrevious props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
intent"primary" | "neutral" | "error" | null | undefined—Semantic purpose: primary action, neutral action, or destructive/error action. Independent of visual emphasis. Defaults to primary.
emphasis"link" | "filled" | "stroke" | "lighter" | "ghost" | null | undefined—Visual weight: filled, stroke, lighter, ghost, or link (text only, underlined on hover). Does not change the action's semantics; use asChild with an anchor when it navigates. Defaults to filled.
size"xs" | "sm" | "md" | "lg" | null | undefined—Control size: xs, sm, md, or lg. Keep labels and icons readable when choosing a size. Defaults to md.
asChildboolean | undefined—Merge styles and behavior into one child element instead of rendering a button. Use a real anchor with href for navigation; native disabled does not disable an anchor. Defaults to false.
iconOnlyboolean | undefined—Square button for a single icon at the selected size. Always provide aria-label (or aria-labelledby) because there is no visible text. Defaults to false.
loadingboolean | undefined—Show a spinner while an operation runs. The button keeps its width and focus, exposes aria-busy and aria-disabled, and ignores activation until loading ends; with asChild the spinner renders inside the child and its onClick and navigation are blocked. Defaults to false.
Inherited props (18)
CarouselPrevious inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLButtonElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
disabledboolean | undefined—Make the supported control unavailable through its native or primitive disabled semantics. This does not disable arbitrary child links.
formstring | undefined—ID of the form associated with this control, including when it is rendered outside that form element.
namestring | undefined—Name used by the control's form submission or primitive form integration.
type"button" | "submit" | "reset" | undefined—Native element or primitive mode defined by the source union. Choose a supported value; its meaning depends on the component.
valuestring | number | readonly string[] | undefined—Current value in the shape defined by the source type. For controlled interactive inputs, apply updates from the change callback.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLButtonElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLButtonElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLButtonElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

Accessibility & usage

From registry/ui/carousel.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • A small set of visual items where browsing is optional: product photos, onboarding steps, recommended articles.
  • A horizontal strip of cards on mobile where showing part of the next card invites swiping.
  • Content where order matters and each slide stands alone, such as a step-by-step tour with a visible position.

When not to use

  • Important content or calls to action; most people never reach slides after the first, so put key content on the page.
  • Auto-advancing banners; they move content away while people read and need extra pause controls (WCAG 2.2.2).
  • Long or comparable lists; a grid, list or table shows more at once and is easier to scan.
  • A simple horizontally scrolling row without slide semantics; a scroll area is lighter.

Anatomy

Carousel
Root region with aria-roledescription="carousel"; sets up Embla with orientation, opts and plugins and exposes the API through setApi. Name it with aria-label.
CarouselContent
The clipped viewport and the flex track of slides; accepts classes for gaps or a fixed height in vertical mode.
CarouselItem
One slide, a group with aria-roledescription="slide"; basis classes set how many are visible. Add an aria-label such as '2 of 5'.
CarouselPrevious
Native button named 'Previous slide'; disabled at the first slide unless loop is on. Absolutely positioned outside the content edge.
CarouselNext
Native button named 'Next slide'; disabled at the last slide unless loop is on.

Keyboard & interaction

  • Previous and next are native buttons: Enter or Space moves one slide; at a boundary they become natively disabled and leave the tab order (unless opts.loop is set).
  • Pointer and touch users can drag or swipe the track (Embla); swiping is never the only way to move, the buttons remain.
  • There is no built-in arrow-key handler on the region; keyboard users use the buttons, and Tab reaches focusable content inside visible slides.
  • setApi gives the Embla API for consumer controls such as a slide counter, dots or scroll-to-index; subscribe to select and reInit and clean up.
  • Plugins such as autoplay are the consumer's responsibility, including a visible pause control, stopping on focus and hover, and honoring reduced motion.

Responsive behavior

  • Change slides per view with basis classes per breakpoint (for example 4/5 on mobile so the next slide peeks, 1/3 on desktop).
  • Reserve space for the arrow buttons (padding or margin on the parent), or reposition them inside the carousel on small screens with className.
  • Keep arrow buttons at least 24x24 CSS pixels; the default 32x32 is fine, larger is better for touch.
  • Vertical orientation needs a fixed height on CarouselContent and space above and below for the rotated buttons.

Content guidelines

  • Name the carousel by its content ('Recommended articles'); avoid generic names like 'Slider'.
  • Label each slide with its position ('3 of 6') and make sure each slide's content makes sense on its own.
  • Show the position visibly when order matters ('Step 2 of 4').
  • Keep text on slides short; put long content on the page or behind a link.
  • Provide text alternatives for image slides.

Alternatives

  • Scroll area — A bounded horizontal strip that scrolls natively without slide semantics or arrow controls.
  • Card — A responsive grid of cards that shows every item at once.
  • Tabs — A few named panels where people choose a view by its label.

Resources