Nuxt UI v3 is officially released!

Components

Carousel

Display images or content in a scrollable area.

Usage

Drag with your mouse, scroll with your mouse wheel or use the navigation arrows to navigate.

Pass an array to the items prop and use the default slot to display the content of each item.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Snap

The carousel will snap the item to the center (snap-center). You can use the snap utility classes to change this behavior using the ui prop:

Snap to start

<template>
  <UCarousel v-slot="{ item }" :items="items" :ui="{ item: 'snap-start' }">
    <img :src="item" width="200" height="300">
  </UCarousel>
</template>

Snap to end

<template>
  <UCarousel v-slot="{ item }" :items="items" :ui="{ item: 'snap-end' }">
    <img :src="item" width="200" height="300">
  </UCarousel>
</template>
Learn more about the scroll-snap-align property on the Tailwind CSS documentation.

Size

Each item will take its own size by default in the carousel. You can use the basis / width utility classes to change this behavior using the ui prop:

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

In this example, we used basis-1/3 to display 3 items at a time but you can also use this to make the carousel full width using basis-full and display only one item at a time:

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

You can also set a width on the container to center the carousel:

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}
Learn more about the flex-basis property on the Tailwind CSS documentation.

Arrows

Use the arrows prop to enable prev and next buttons, they will be automatically disabled when the carousel reaches the first or last item.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

You can also customize the prev and next buttons using the prev-button and next-button props:

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

In this example, we move the buttons outside of the carousel container. You can also change this globally in ui.carousel.default.prevButton and ui.carousel.default.nextButton.

Indicators

Use the indicators prop to display a list of buttons at the bottom of the carousel to navigate between items.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

The number of indicators will be automatically generated based on the number of items:

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Autoplay

You can easily implement an autoplay behavior using the exposed API through a template ref.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Slots

default

You can put anything inside the default slot, not only images. You will have access to the item and index properties in the slot scope.

Sébastien Chopin

1. Sébastien Chopin

Pooya Parsa

2. Pooya Parsa

Daniel Roe

3. Daniel Roe

Anthony Fu

4. Anthony Fu

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

prev / next

With the arrows prop enabled, use the #prev and #next slots to set the content of the previous and next buttons. You will have access to the disabled property and on-click method in the slot scope.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}
You can customize the position of the buttons through ui.arrows.wrapper.

indicator

With the indicators prop enabled, use the #indicator slot to set the content of the indicators. You will have access to the active, page properties and on-click method in the slot scope.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}
You can customize the position of the buttons through ui.indicators.wrapper.

Props

ui
{ wrapper?: string; container?: string; item?: string; arrows?: DeepPartial<{ wrapper: string; }, any>; indicators?: DeepPartial<{ wrapper: string; base: string; active: string; inactive: string; }, any>; default?: DeepPartial<{ prevButton: { color: ButtonColor; class: string; icon: string; }; nextButton: { color: ButtonColor; class: string; icon: string; }; }, any>; } & { [key: string]: any; } & { strategy?: Strategy; }
undefined
items
any[]
[]
dir
"ltr" | "rtl"
"ltr"
prevButton
Button & { class?: string; }
config.default.prevButton as Button & { class?: string; }
nextButton
Button & { class?: string; }
config.default.nextButton as Button & { class?: string; }
arrows
boolean
false
indicators
boolean
false

API

When accessing the component via a template ref, you can use the following:

page
number

The current page.

pages
number

The total number of pages.

select (page)

Go to a specific page.

next ()

Go to the next page.

prev ()

Go to the previous page.

Config

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}