---
title: "carousel"
description: "Horizontally scrolling slides with snap points and arrow controls."
category: "Data Display"
---
# carousel
Horizontally scrolling slides with snap points and arrow controls.
## Installation
```bash
php artisan ui:add carousel
```
## Dependencies
- composer: `gehrisandro/tailwind-merge-laravel`
## Usage
```blade
@foreach ($slides as $slide)
{{-- basis-full by default; use class="basis-1/2" for a multi-up row. --}}
{{ $slide }}
@endforeach
```
## Example
The demo rendered on the docs page.
```blade
@foreach (range(1, 5) as $i)
{{ $i }}
@endforeach
```
## Source
Copy each file to the path shown above it.
`resources/views/components/ui/carousel/index.blade.php`
```blade
@props([])
@php
$classes = \TailwindMerge\Laravel\Facades\TailwindMerge::merge(
'relative',
$attributes->get('class'),
);
$arrow =
'absolute top-1/2 z-10 flex size-8 -translate-y-1/2 items-center justify-center rounded-full border border-input bg-background shadow-xs outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 dark:bg-input/30 dark:hover:bg-input/50';
@endphp
{{-- Scroll-snap carries the whole interaction: swipe, trackpad, scrollbar
dragging and keyboard scrolling are the browser's, not ours. The only
thing script is needed for is the two arrow buttons, which have no
declarative equivalent. Strip the script and everything else still
works. --}}
except('class')->merge(['class' => $classes]) }}>
{{ $slot }}
@once
@endonce
```
`resources/views/components/ui/carousel/item.blade.php`
```blade
@props([])
@php
// basis-full shows one slide at a time. Override it through class for a
// multi-up carousel, e.g. class="basis-1/2 md:basis-1/3".
$classes = \TailwindMerge\Laravel\Facades\TailwindMerge::merge(
'min-w-0 shrink-0 grow-0 basis-full snap-start',
$attributes->get('class'),
);
@endphp