NovaUI
Components

Carousel

A scrollable carousel component with navigation controls for cycling through content.

The Carousel component provides a scrollable container with navigation arrows for cycling through slides. It supports horizontal and vertical orientations, auto-sizing based on item dimensions, and exposes a CarouselApi for programmatic control.

Preview

1
2
3

Installation

npx novaui-cli add carousel

Import

import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselPrevious,
  CarouselNext,
} from 'novaui-components'

Basic Usage

1
2
3
4
5
import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselPrevious,
  CarouselNext,
} from 'novaui-components'
import { View, Text } from 'react-native'

export function BasicCarousel() {
  return (
    <Carousel className="w-full max-w-xs">
      <CarouselContent>
        {[1, 2, 3, 4, 5].map((item) => (
          <CarouselItem key={item}>
            <View className="p-1">
              <View className="rounded-md border border-border bg-muted p-6 items-center justify-center">
                <Text className="text-3xl font-semibold text-foreground">
                  {item}
                </Text>
              </View>
            </View>
          </CarouselItem>
        ))}
      </CarouselContent>
      <CarouselPrevious />
      <CarouselNext />
    </Carousel>
  )
}

Vertical Orientation

1
2
3
<Carousel orientation="vertical" className="w-full max-w-xs">
  <CarouselContent>
    {[1, 2, 3].map((item) => (
      <CarouselItem key={item}>
        <View className="p-1">
          <View className="rounded-md border border-border bg-muted p-6 items-center justify-center">
            <Text className="text-3xl font-semibold">{item}</Text>
          </View>
        </View>
      </CarouselItem>
    ))}
  </CarouselContent>
  <CarouselPrevious />
  <CarouselNext />
</Carousel>

With API Control

Use the setApi callback for programmatic carousel control:

import { useState } from 'react'
import { type CarouselApi } from 'novaui-components'

export function ControlledCarousel() {
  const [api, setApi] = useState<CarouselApi>()

  return (
    <View className="gap-4">
      <Carousel setApi={setApi}>
        <CarouselContent>
          {[1, 2, 3].map((item) => (
            <CarouselItem key={item}>
              <View className="rounded-md border border-border bg-muted p-6 items-center justify-center">
                <Text className="text-3xl font-semibold">{item}</Text>
              </View>
            </CarouselItem>
          ))}
        </CarouselContent>
      </Carousel>
      <View className="flex-row gap-2">
        <Button label="Prev" onPress={() => api?.scrollPrev()} />
        <Button label="Next" onPress={() => api?.scrollNext()} />
      </View>
    </View>
  )
}

Props API

Extends React.ComponentPropsWithoutRef<typeof View>:

PropTypeDefaultDescription
orientation'horizontal' | 'vertical''horizontal'Scroll direction
setApi(api: CarouselApi) => void-Callback to receive the carousel API
classNamestring-Additional CSS classes

CarouselApi

MethodTypeDescription
scrollPrev() => voidScroll to the previous slide
scrollNext() => voidScroll to the next slide
scrollTo(index: number) => voidScroll to a specific slide
canScrollPrevbooleanWhether there is a previous slide
canScrollNextbooleanWhether there is a next slide

CarouselContent

Extends React.ComponentPropsWithoutRef<typeof View>:

PropTypeDefaultDescription
classNamestring-Additional CSS classes

CarouselItem

Extends React.ComponentPropsWithoutRef<typeof View>:

PropTypeDefaultDescription
classNamestring-Additional CSS classes

CarouselPrevious / CarouselNext

Extends Button props:

PropTypeDefaultDescription
variantstring'outline'Button variant
sizestring'icon'Button size
classNamestring-Additional CSS classes

Best Practices

  1. Provide navigation: Always include CarouselPrevious and CarouselNext or a programmatic control
  2. Keep slides consistent: Use the same height and layout for all carousel items
  3. Limit slide count: Avoid too many slides — consider pagination for large datasets
  4. Indicate position: Show slide indicators or counts so users know their position
  5. Use appropriate orientation: Vertical carousels work well for card stacks and galleries
  • Scroll Area - For generic scrollable containers
  • Tabs - For tabbed content switching

On this page