Carousel
Dot Pager
A carousel whose dots are real buttons labelled "Slide N of M": arrow keys walk the row and the track moves by transform rather than scrolling.
- carousel
- dots
- keyboard
- slider
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/carousel-009?lang=en
Северный маршрут
Четыре дня вдоль побережья с ночёвками в деревянных домах
Show the full instructions
What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.
# Install and place "carousel-009" (Dot Pager) from VibeUI
## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/carousel-009.json
Registry item: https://vibeui.ru/r/carousel-009.json
Installs to: components/vibeui/carousel-009.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.
Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.
## 2. What it is
A carousel whose dots are real buttons labelled "Slide N of M": arrow keys walk the row and the track moves by transform rather than scrolling.
A carousel with real dot buttons, arrow-key navigation and a transform-driven track. Zero dependencies, one file.
## 3. How to use it
import { Carousel009 } from "@/components/vibeui/carousel-009"
<Carousel009
label="Routes"
slides={[
{ title: "Northern route", text: "Four days along the coast", hue: 220 },
{ title: "Mountain loop", text: "A sunrise climb", hue: 150 },
]}
/>
Read the installed file for the full prop list.
## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.
Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)
## 5. Keep exactly as installed
- the local --vibeui-carousel-009-* palette — do not swap it for your theme tokens
- the dots as real buttons labelled "Slide N of M": a div has neither role nor name
- inert and aria-hidden on the off-screen slides — otherwise Tab reaches hidden content
- the position as a number in --vibeui-carousel-009-index: scrolling drifts away from the dots
- moving focus to the chosen dot on arrow keys, otherwise the keyboard loses its place
- aria-current on the active dot: its width and colour mean nothing to a screen reader
## 6. You may change
- the slides through slides: title, text and hue
- the carousel label through label
- the accent colour through accent
- the travel duration in the transition rule of [data-part="track"]
## 7. Rules
- More than eight dots stop reading as a position: long decks need a counter instead.
- There is no touch swipe: the track moves by transform, not by scrolling.
- There is deliberately no autoplay — it would require pausing on hover and focus.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.
## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.For developers
npx shadcn@latest add https://vibeui.ru/r/carousel-009.jsonhttps://vibeui.ru/r/carousel-009.jsonКомпонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-carousel-009-*. Клиентский ("use client") — позицию держит useState. Лента сдвигается translateX от переменной --vibeui-carousel-009-index: позиция задаётся числом и не зависит от того, куда докрутили пальцем, поэтому точка и кадр не расходятся. Стрелки, Home и End обрабатываются на контейнере точек и переносят фокус на выбранную точку. Невидимые слайды помечены inert и aria-hidden — иначе Tab уходит за край кадра к недоступному содержимому.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useRef, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Carousel009Slide = {
title: string
text?: string
hue?: number
}
export type Carousel009Props = Omit<
ComponentPropsWithoutRef<"section">,
"children"
> & {
slides?: Carousel009Slide[]
label?: string
accent?: string
}
// Идея компонента: точки — не украшение, а полноценный переключатель.
// Каждая точка это <button> с подписью «Слайд N из M», в ряду точек работают
// стрелки клавиатуры с переносом фокуса на выбранную точку, а лента едет
// трансформацией, а не прокруткой: так позиция задаётся числом и не зависит
// от того, куда пользователь докрутил пальцем. Невидимые слайды помечены
// inert, иначе Tab уходит за край кадра.
const STYLES = `
:where([data-vibeui-block="carousel-009"]){
--vibeui-carousel-009-bg:oklch(1 0 0);
--vibeui-carousel-009-fg:oklch(0.22 0.014 265);
--vibeui-carousel-009-muted:oklch(0.58 0.014 265);
--vibeui-carousel-009-border:oklch(0.91 0.006 265);
--vibeui-carousel-009-accent:oklch(0.55 0.19 262);
--vibeui-carousel-009-index:0;
--vibeui-carousel-009-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="carousel-009"]{
display:flex;flex-direction:column;gap:0.625rem;
width:100%;max-width:26rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-carousel-009-bg);
border:1px solid var(--vibeui-carousel-009-border);border-radius:1rem;
font-family:var(--vibeui-carousel-009-font);color:var(--vibeui-carousel-009-fg);
}
[data-vibeui-block="carousel-009"] [data-part="window"]{overflow:hidden;border-radius:0.875rem}
/* Позиция задаётся числом: одна переменная вместо прокрутки и её округлений. */
[data-vibeui-block="carousel-009"] [data-part="track"]{
display:flex;margin:0;padding:0;list-style:none;
transform:translateX(calc(var(--vibeui-carousel-009-index) * -100%));
transition:transform .32s ease;
}
[data-vibeui-block="carousel-009"] [data-part="slide"]{
flex:0 0 100%;min-width:0;
display:flex;flex-direction:column;justify-content:flex-end;gap:0.25rem;
aspect-ratio:16 / 9;padding:1rem;box-sizing:border-box;
background:
radial-gradient(90% 80% at 22% 18%,oklch(0.9 0.06 var(--vibeui-carousel-009-hue,250)),transparent 70%),
linear-gradient(150deg,oklch(0.74 0.1 var(--vibeui-carousel-009-hue,250)),oklch(0.44 0.11 var(--vibeui-carousel-009-hue,250)));
color:oklch(0.99 0.003 265);
}
[data-vibeui-block="carousel-009"] [data-part="title"]{margin:0;font-size:1.0625rem;font-weight:680;line-height:1.2}
[data-vibeui-block="carousel-009"] [data-part="text"]{margin:0;font-size:0.8125rem;line-height:1.45;color:oklch(0.94 0.01 265);max-width:20rem}
[data-vibeui-block="carousel-009"] [data-part="dots"]{
display:flex;justify-content:center;align-items:center;gap:0.375rem;
}
/* Точка — настоящая кнопка с подписью: у неё есть фокус, роль и имя. */
[data-vibeui-block="carousel-009"] [data-part="dot"]{
appearance:none;cursor:pointer;padding:0;
width:1.5rem;height:1.5rem;border:0;border-radius:9999px;background:transparent;
display:inline-flex;align-items:center;justify-content:center;
}
[data-vibeui-block="carousel-009"] [data-part="dot"]::before{
content:"";width:0.5rem;height:0.5rem;border-radius:9999px;
background:var(--vibeui-carousel-009-border);
transition:background-color .16s ease,width .16s ease;
}
[data-vibeui-block="carousel-009"] [data-part="dot"]:hover::before{background:var(--vibeui-carousel-009-muted)}
[data-vibeui-block="carousel-009"] [data-part="dot"][aria-current="true"]::before{
width:1.125rem;background:var(--vibeui-carousel-009-accent);
}
[data-vibeui-block="carousel-009"] [data-part="dot"]:focus-visible{outline:2px solid var(--vibeui-carousel-009-accent);outline-offset:0}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="carousel-009"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_SLIDES: Carousel009Slide[] = [
{
title: "Северный маршрут",
text: "Четыре дня вдоль побережья с ночёвками в деревянных домах",
hue: 220,
},
{
title: "Горная петля",
text: "Подъём на рассвете и спуск к озеру тем же днём",
hue: 150,
},
{
title: "Городские крыши",
text: "Вечерняя прогулка по старым кварталам с гидом",
hue: 30,
},
{
title: "Долина ветров",
text: "Два перевала и ночёвка в палатке",
hue: 285,
},
]
/**
* Карусель с точками-кнопками и управлением стрелками клавиатуры.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Carousel009({
slides = DEFAULT_SLIDES,
label = "Маршруты",
accent,
className,
style,
...props
}: Carousel009Props) {
const [index, setIndex] = useState(0)
const dots = useRef<HTMLDivElement>(null)
function go(next: number) {
const target = (next + slides.length) % slides.length
setIndex(target)
const buttons = dots.current?.querySelectorAll("[data-part='dot']")
;(buttons?.[target] as HTMLButtonElement | undefined)?.focus()
}
const palette = {
"--vibeui-carousel-009-index": index,
...(accent ? { "--vibeui-carousel-009-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-carousel-009" precedence="medium">
{STYLES}
</style>
<section
{...props}
data-vibeui-block="carousel-009"
aria-roledescription="карусель"
aria-label={label}
className={className}
style={palette}
>
<div data-part="window">
<ul data-part="track">
{slides.map((slide, position) => (
<li
data-part="slide"
key={slide.title}
inert={position !== index}
aria-hidden={position !== index}
style={
{
"--vibeui-carousel-009-hue": slide.hue ?? 250,
} as CSSProperties
}
>
<h3 data-part="title">{slide.title}</h3>
{slide.text ? <p data-part="text">{slide.text}</p> : null}
</li>
))}
</ul>
</div>
<div
data-part="dots"
ref={dots}
role="group"
aria-label="Переключение слайдов"
onKeyDown={(event) => {
if (event.key === "ArrowRight") {
event.preventDefault()
go(index + 1)
}
if (event.key === "ArrowLeft") {
event.preventDefault()
go(index - 1)
}
if (event.key === "Home") {
event.preventDefault()
go(0)
}
if (event.key === "End") {
event.preventDefault()
go(slides.length - 1)
}
}}
>
{slides.map((slide, position) => (
<button
key={slide.title}
type="button"
data-part="dot"
aria-current={position === index}
aria-label={`Слайд ${position + 1} из ${slides.length}: ${slide.title}`}
onClick={() => setIndex(position)}
/>
))}
</div>
</section>
</>
)
}