Carousel

A swipeable track of slides.

1
2
3
4
5
<Carousel.Root opts={{ loop: true }}>
	<Carousel.Content>
		<Carousel.Item>…</Carousel.Item>
	</Carousel.Content>
	<Carousel.Previous />
	<Carousel.Next />
	<Carousel.Dots />
</Carousel.Root>

Built on Embla; opts goes straight to it. The arrows sit outside the track, so leave horizontal room around the carousel or they will clip.

basis-1/3 on the items shows three at a time — the track does not have a "slides per view" prop because that is what the width is for.

API

Carousel.Root

PropTypeDefault
optsPartial<OptionsType>
orientation"horizontal" | "vertical""horizontal"
pluginsCreatePluginType<LoosePluginType, {}>[]
setApi((api: EmblaCarouselType | undefined) => void)

Plus every <div> prop. Source: carousel/components/carousel-root.tsx.

Carousel.Content

PropTypeDefault
containerClassNamestring

Plus every <div> prop. Source: carousel/components/carousel-content.tsx.

Carousel.Dots

Plus every <div> prop. Source: carousel/components/carousel-dots.tsx.

Carousel.Item

PropTypeDefault
renderComponentRenderFn<HTMLProps, {}> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.

Plus every <div> prop. Source: carousel/components/carousel-item.tsx.

Carousel.Next

PropTypeDefault
insetbooleanfalse
loadingbooleanShow a leading spinner and mark the button aria-busy, disabling interaction while an async action is in flight (e.g. a form submit).
shape"default" | "pill"pill forces a fully rounded button; default follows the theme's --radius, so it changes with the brand.
size"default" | "icon" | "icon-lg" | "icon-sm" | "icon-xs" | "lg" | "sm" | "xs""icon-sm"Height and horizontal padding. The icon-* set is square, for a button whose entire content is one icon — give those an aria-label.
variant"brand" | "default" | "destructive" | "ghost" | "highlight" | "link" | "outline" | "primary" | "secondary""outline"Weight of the action. default is the one thing the page exists for, at most one per view; secondary an equal-weight alternative; outline for toolbars and anything that repeats in a row; ghost inside dense surfaces; destructive for what cannot be undone; link for an action that reads as navigation.
classNamestring | ((state: ButtonState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
focusableWhenDisabledbooleanWhether the button should be focusable when disabled.
nativeButtonbooleanWhether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).
renderComponentRenderFn<HTMLProps, ButtonState> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
styleCSSProperties | ((state: ButtonState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: carousel/components/carousel-next.tsx.

Carousel.Previous

PropTypeDefault
insetbooleanfalse
loadingbooleanShow a leading spinner and mark the button aria-busy, disabling interaction while an async action is in flight (e.g. a form submit).
shape"default" | "pill"pill forces a fully rounded button; default follows the theme's --radius, so it changes with the brand.
size"default" | "icon" | "icon-lg" | "icon-sm" | "icon-xs" | "lg" | "sm" | "xs""icon-sm"Height and horizontal padding. The icon-* set is square, for a button whose entire content is one icon — give those an aria-label.
variant"brand" | "default" | "destructive" | "ghost" | "highlight" | "link" | "outline" | "primary" | "secondary""outline"Weight of the action. default is the one thing the page exists for, at most one per view; secondary an equal-weight alternative; outline for toolbars and anything that repeats in a row; ghost inside dense surfaces; destructive for what cannot be undone; link for an action that reads as navigation.
classNamestring | ((state: ButtonState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
focusableWhenDisabledbooleanWhether the button should be focusable when disabled.
nativeButtonbooleanWhether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).
renderComponentRenderFn<HTMLProps, ButtonState> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
styleCSSProperties | ((state: ButtonState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: carousel/components/carousel-previous.tsx.