Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/app/assets/icons/embla-carousel.svg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ const items = [
<template>
<UCarousel
v-slot="{ item }"
class-names
arrows
:items="items"
:ui="{
item: 'basis-[70%] transition-opacity [&:not(.is-snapped)]:opacity-10'
item: 'basis-[70%] transition-opacity not-data-active:opacity-10'
}"
class="mx-auto max-w-sm"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const items = [
dots
:items="items"
:ui="{
container: 'transition-[height]',
viewport: 'transition-[height]',
controls: 'absolute -top-8 inset-x-12',
dots: '-top-7',
dot: 'w-6 h-1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,25 @@ const items = [
'https://picsum.photos/640/640?random=5',
'https://picsum.photos/640/640?random=6'
]

const carousel = useTemplateRef('carousel')
const activeIndex = ref(0)

function onClickPrev() {
activeIndex.value--
}
function onClickNext() {
activeIndex.value++
}
function onSelect(index: number) {
activeIndex.value = index
}

function select(index: number) {
activeIndex.value = index

carousel.value?.emblaApi?.scrollTo(index)
}
</script>

<template>
<div class="flex-1 w-full">
<UCarousel
ref="carousel"
v-slot="{ item }"
arrows
:items="items"
:prev="{ onClick: onClickPrev }"
:next="{ onClick: onClickNext }"
class="w-full max-w-xs mx-auto"
@select="onSelect"
>
<UCarousel
arrows
dots
:items="items"
:ui="{
dots: 'static flex-nowrap justify-between gap-1 pt-4',
dot: 'size-11 rounded-lg bg-transparent data-[state=active]:bg-transparent opacity-25 hover:opacity-100 data-[state=active]:opacity-100 transition-opacity'
}"
class="w-full max-w-xs mx-auto"
>
<template #default="{ item }">
<img :src="item" width="320" height="320" class="rounded-lg" loading="lazy">
</UCarousel>
</template>

<div class="flex gap-1 justify-between pt-4 max-w-xs mx-auto">
<div
v-for="(item, index) in items"
:key="index"
class="size-11 opacity-25 hover:opacity-100 transition-opacity"
:class="{ 'opacity-100': activeIndex === index }"
@click="select(index)"
>
<img :src="item" width="44" height="44" class="rounded-lg" loading="lazy">
</div>
</div>
</div>
<template #dot="{ index }">
<img :src="items[index]" width="44" height="44" class="rounded-lg" loading="lazy">
</template>
</UCarousel>
</template>
103 changes: 80 additions & 23 deletions docs/content/docs/1.getting-started/3.migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Nuxt UI v5 needs Tailwind CSS 4.2 or later, see [Canonical Tailwind classes](#ca

### Optional peer dependencies

The dependencies of the [`Editor`](/docs/components/editor), [`Carousel`](/docs/components/carousel) and [`Table`](/docs/components/table) components are no longer installed with Nuxt UI. They are optional peer dependencies, so projects that don't use these components no longer download them.
The dependencies of the [`Editor`](/docs/components/editor) and [`Table`](/docs/components/table) components are no longer installed with Nuxt UI. They are optional peer dependencies, so projects that don't use these components no longer download them.

If you use the `Editor` component, install TipTap:

Expand All @@ -106,28 +106,6 @@ bun add @tiptap/core @tiptap/extension-bubble-menu @tiptap/extension-code @tipta

`@tiptap/extension-collaboration` and `@tiptap/extension-node-range` are no longer installed either, add them if you import them.

If you use the `Carousel` component, install Embla:

::code-group{sync="pm"}

```bash [pnpm]
pnpm add embla-carousel embla-carousel-auto-height embla-carousel-auto-scroll embla-carousel-autoplay embla-carousel-class-names embla-carousel-fade embla-carousel-vue embla-carousel-wheel-gestures
```

```bash [yarn]
yarn add embla-carousel embla-carousel-auto-height embla-carousel-auto-scroll embla-carousel-autoplay embla-carousel-class-names embla-carousel-fade embla-carousel-vue embla-carousel-wheel-gestures
```

```bash [npm]
npm install embla-carousel embla-carousel-auto-height embla-carousel-auto-scroll embla-carousel-autoplay embla-carousel-class-names embla-carousel-fade embla-carousel-vue embla-carousel-wheel-gestures
```

```bash [bun]
bun add embla-carousel embla-carousel-auto-height embla-carousel-auto-scroll embla-carousel-autoplay embla-carousel-class-names embla-carousel-fade embla-carousel-vue embla-carousel-wheel-gestures
```

::

If you use the `Table` component, install TanStack Table:

::code-group{sync="pm"}
Expand Down Expand Up @@ -1689,3 +1667,82 @@ Two parts of this can't be handled by a find-and-replace:

- Removing `shouldScaleBackground` also removes the effect it enabled. The page behind the drawer no longer scales down, and the `data-vaul-drawer-wrapper` attribute it required can be deleted from your app root.
- The `data-vaul-*` attributes are gone from the DOM. Any CSS or test selector written against them moves to the `drawer-*` values covered in [`data-slot` attributes](#data-slot-attributes), or to the Reka UI attributes `data-state`, `data-swipe-direction` and `data-swiping`.

### Carousel built on Reka UI

The [`Carousel`](/docs/components/carousel) component is now built on Reka UI's `Carousel` primitive and the `embla-carousel*` packages are no longer used. You can uninstall them:

```diff [package.json]
-"embla-carousel": "^8.6.0",
-"embla-carousel-auto-height": "^8.6.0",
-"embla-carousel-auto-scroll": "^8.6.0",
-"embla-carousel-autoplay": "^8.6.0",
-"embla-carousel-class-names": "^8.6.0",
-"embla-carousel-fade": "^8.6.0",
-"embla-carousel-vue": "^8.6.0",
-"embla-carousel-wheel-gestures": "^8.1.0"
```

The current snap is now a `v-model`, so `start-index` becomes `default-value` and the `select` event becomes `update:model-value`. Like `start-index`, the value is a snap index, which covers several slides when `slides-to-scroll` is greater than 1:

```diff
-<UCarousel :start-index="2" @select="onSelect">
+<UCarousel :default-value="2" @update:model-value="onSelect">
```

`emblaRef` and `emblaApi` are no longer exposed. The component exposes `scrollPrev`, `scrollNext`, `scrollTo`, `play` and `stop` instead, with `snapCount`, `canScrollPrev` and `canScrollNext`:

```diff
-carousel.value?.emblaApi?.scrollTo(2)
+carousel.value?.scrollTo(2)
```

The `auto-height`, `fade` and `wheel-gestures` props are now booleans and no longer take Embla plugin options. `autoplay` takes `delay`, `stopOnInteraction` and `stopOnLastSnap`, and `auto-scroll` takes `speed`, `direction` and `stopOnInteraction`. `delay` is a single number of milliseconds, Embla's function form that set a delay per snap has no equivalent. The `speed` of `auto-scroll` is now in pixels per second, `2` in v4 is about `120`:

```diff
-<UCarousel :auto-scroll="{ speed: 2 }">
+<UCarousel :auto-scroll="{ speed: 120 }">
```

`playOnInit` has no equivalent and the rotation starts on mount. Set `default-playing` to `false` to start paused:

```diff
-<UCarousel :autoplay="{ playOnInit: false }">
+<UCarousel autoplay :default-playing="false">
```

The `class-names` prop is removed. The slides get `data-active` and `data-in-view` attributes instead of the `is-snapped` and `is-in-view` classes:

```diff
-<UCarousel class-names :ui="{ item: 'transition-opacity [&:not(.is-snapped)]:opacity-10' }">
+<UCarousel :ui="{ item: 'transition-opacity not-data-active:opacity-10' }">
```

The Embla options that have no equivalent are removed: `active`, `breakpoints`, `dragThreshold`, `duration`, `watchResize`, `watchSlides` and `watchFocus`. `watchDrag` becomes `draggable`:

```diff
-<UCarousel :watch-drag="false">
+<UCarousel :draggable="false">
```

The `auto-height` height is now set on the `viewport` instead of the `container`, so move its transition:

```diff
-<UCarousel auto-height :ui="{ container: 'transition-[height]' }">
+<UCarousel auto-height :ui="{ viewport: 'transition-[height]' }">
```

The slides and the dots are now labelled `1 of 6` through a new `carousel.slideLabel` locale key, and `carousel.goto` is removed. A custom locale made with `defineLocale` has to follow:

```diff
carousel: {
- goto: 'Go to slide {slide}',
+ slideLabel: '{slide} of {total}',
}
```

Three parts of this can't be handled by a find-and-replace:

- `emblaApi` calls have to be rewritten by hand. Its other methods, such as `scrollProgress` or `slidesInView`, have no replacement.
- The viewport is now a native scroll container with CSS scroll snapping, and `autoplay` always pauses while the mouse is over the carousel. Slides move with the browser's smooth scrolling instead of Embla's animation.
- Embla's `is-snapped`, `is-in-view`, `is-draggable` and `is-dragging` classes are gone from the DOM. CSS and test selectors written against them move to `data-active`, `data-in-view` and the `data-dragging` attribute of the viewport.
Loading
Loading