codefast/ui

Command Palette

Search for a command to run...

Display

Carousel

Embla-powered slide carousel with prev/next controls. Supports horizontal and vertical axes.

Install

pnpm add @codefast/ui

Import path

@codefast/ui/carousel

Examples

Multiple per view

Show several items at once with basis utilities.

1
2
3
4
5

Anatomy

How the parts compose. Copy this skeleton and fill in the slots.

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

<Carousel setApi={setApi}>
  <CarouselContent>
    <CarouselItem>…</CarouselItem>
  </CarouselContent>
  <CarouselPrevious />
  <CarouselNext />
</Carousel>

API reference

Props for each part of the component. All native element props are also forwarded.

Carousel

Embla-powered. Owns the viewport and exposes the underlying api.

PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Scroll axis.
optsEmblaOptionsTypeEmbla options, e.g. { align: "start", loop: true }.
setApi(api) => voidReceive the Embla api to read the index or call scrollTo().
pluginsEmblaPluginType[]Embla plugins such as Autoplay.

CarouselItem

PropTypeDefaultDescription
classNamestringSet basis-1/2, basis-1/3… to show multiple items per view.

Accessibility

Built to be keyboard-navigable and screen-reader friendly out of the box.

KeyFunction
TabFocuses the carousel region, then the prev/next buttons.
Arrow+LeftScrolls to the previous slide.
Arrow+RightScrolls to the next slide.
  • The region is labelled as a carousel; prev/next buttons disable at the ends.
  • Provide a text counter or labelled dots so position isn’t conveyed only visually.
  • Avoid autoplay for essential content, or pause it on hover/focus.

Guidelines

Conventions that keep usage consistent across an app.

Do

  • Show position with a counter or dot indicators.
  • Use basis utilities on items to reveal a peek of the next slide.

Don’t

  • Don’t hide critical content inside an autoplaying carousel.
  • Don’t remove the prev/next controls on non-touch devices.