Display
Snap Card Rail
A horizontal rail with snapping: the scroll always stops at the start of a card rather than mid-card, and the last card never presses against the edge of the area.
- scrollarea
- carousel
- snap
- display
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/scrollarea-003?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 "scrollarea-003" (Snap Card Rail) 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/scrollarea-003.json
Registry item: https://vibeui.ru/r/scrollarea-003.json
Installs to: components/vibeui/scrollarea-003.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 horizontal rail with snapping: the scroll always stops at the start of a card rather than mid-card, and the last card never presses against the edge of the area.
A horizontal card rail that snaps to card starts and scrolls from the keyboard. Zero dependencies, one file, server rendered.
## 3. How to use it
import { Scrollarea003 } from "@/components/vibeui/scrollarea-003"
<Scrollarea003
title="Ready-made blocks"
cards={[{ title: "Hero Split", meta: "block · 2 min" }]}
cardWidth="9.5rem"
/>
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-scrollarea-003-* palette — do not swap it for your theme tokens
- the pair of scroll-snap-type and scroll-snap-align: neither snaps anything alone
- scroll-padding-inline matching the rail's own padding, or the card snaps flush to the edge
- the padding on the rail rather than the container — otherwise the last card is clipped
- tabindex="0" and role="region" with aria-label on the rail: without them it cannot be scrolled by keyboard
- its own light surface: the cards and captions are dark and vanish on a dark ground
## 6. You may change
- the heading through title
- the card set through cards
- the card width through cardWidth
- the thumbnail ratio and card radii in CSS
## 7. Rules
- mandatory forbids resting between cards: proximity is gentler for long rails.
- There are deliberately no prev/next buttons — they need client code and a node reference.
- On inertial trackpads snapping sometimes skips a card: that is browser behaviour, not the component.
- 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/scrollarea-003.jsonhttps://vibeui.ru/r/scrollarea-003.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-scrollarea-003-*. Серверный: хуков и обработчиков нет. Прилипание собрано из пары свойств: scroll-snap-type: x mandatory на ленте и scroll-snap-align: start на карточках; scroll-padding-inline повторяет внутренний отступ, поэтому прилипшая карточка не прижимается к самой границе. Внутренние отступы у ленты, а не у контейнера: иначе последняя карточка обрезалась бы краем прокрутки. Лента получает tabindex="0" и role="region" с aria-label, чтобы её можно было листать с клавиатуры. Ширина карточки вынесена в переменную: от неё зависит, сколько видно за раз.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Scrollarea003Card = {
title: string
meta: string
}
export type Scrollarea003Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "title"
> & {
title?: string
cards?: Scrollarea003Card[]
/** Ширина карточки в ленте: от неё зависит, сколько видно за раз. */
cardWidth?: string
}
// Идея компонента: горизонтальная лента с прилипанием. scroll-snap-align на
// карточках плюс scroll-padding у ленты — и остановка всегда приходится на
// начало карточки, а не на её середину. Последняя карточка не упирается в
// край: у ленты есть внутренние отступы, поэтому её видно целиком.
const STYLES = `
:where([data-vibeui-block="scrollarea-003"]){
--vibeui-scrollarea-003-bg:oklch(1 0 0);
--vibeui-scrollarea-003-fg:oklch(0.24 0.014 265);
--vibeui-scrollarea-003-muted:oklch(0.55 0.014 265);
--vibeui-scrollarea-003-border:oklch(0.9 0.006 265);
--vibeui-scrollarea-003-tile:oklch(0.97 0.008 265);
--vibeui-scrollarea-003-accent:oklch(0.55 0.17 265);
--vibeui-scrollarea-003-card:9.5rem;
--vibeui-scrollarea-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="scrollarea-003"]{
display:flex;flex-direction:column;gap:0.625rem;
width:100%;max-width:28rem;box-sizing:border-box;padding:0.875rem 0;
background:var(--vibeui-scrollarea-003-bg);
border:1px solid var(--vibeui-scrollarea-003-border);border-radius:1rem;
font-family:var(--vibeui-scrollarea-003-font);color:var(--vibeui-scrollarea-003-fg);
}
[data-vibeui-block="scrollarea-003"] [data-part="head"]{
display:flex;align-items:baseline;justify-content:space-between;gap:0.75rem;
padding:0 1rem;font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="scrollarea-003"] [data-part="hint"]{
font-weight:500;font-size:0.6875rem;color:var(--vibeui-scrollarea-003-muted);
}
/* Прилипание: остановка всегда на начале карточки, а не на её середине. */
[data-vibeui-block="scrollarea-003"] [data-part="rail"]{
display:flex;gap:0.625rem;
padding:0.125rem 1rem 0.625rem;
overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin;
scroll-snap-type:x mandatory;scroll-padding-inline:1rem;
}
[data-vibeui-block="scrollarea-003"] [data-part="rail"]:focus-visible{
outline:2px solid var(--vibeui-scrollarea-003-accent);outline-offset:-2px;border-radius:0.5rem;
}
[data-vibeui-block="scrollarea-003"] [data-part="card"]{
flex:none;box-sizing:border-box;
width:var(--vibeui-scrollarea-003-card);
scroll-snap-align:start;
display:flex;flex-direction:column;gap:0.375rem;
padding:0.75rem;border-radius:0.75rem;
background:var(--vibeui-scrollarea-003-tile);
border:1px solid var(--vibeui-scrollarea-003-border);
}
[data-vibeui-block="scrollarea-003"] [data-part="thumb"]{
aspect-ratio:16 / 10;border-radius:0.5rem;
background:linear-gradient(135deg,oklch(0.88 0.06 265),oklch(0.93 0.03 200));
}
[data-vibeui-block="scrollarea-003"] [data-part="name"]{
font-size:0.75rem;font-weight:650;line-height:1.25;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="scrollarea-003"] [data-part="meta"]{
font-size:0.6875rem;color:var(--vibeui-scrollarea-003-muted);
}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="scrollarea-003"] *{animation:none!important;transition:none!important}
[data-vibeui-block="scrollarea-003"] [data-part="rail"]{scroll-behavior:auto}
}
`
const DEFAULT_CARDS: Scrollarea003Card[] = [
{ title: "Hero Split", meta: "блок · 2 мин" },
{ title: "Pricing Trio", meta: "блок · 3 мин" },
{ title: "Feature Grid", meta: "блок · 2 мин" },
{ title: "Testimonial Wall", meta: "блок · 4 мин" },
{ title: "FAQ Accordion", meta: "блок · 2 мин" },
{ title: "Footer Columns", meta: "блок · 1 мин" },
]
/**
* Горизонтальная лента с прилипанием карточек.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Scrollarea003({
title = "Готовые блоки",
cards = DEFAULT_CARDS,
cardWidth = "9.5rem",
className,
style,
...props
}: Scrollarea003Props) {
const palette = {
"--vibeui-scrollarea-003-card": cardWidth,
...style,
} as CSSProperties
return (
<>
<style href="vibeui-scrollarea-003" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="scrollarea-003"
className={className}
style={palette}
>
<div data-part="head">
<span>{title}</span>
<span data-part="hint">листайте вбок</span>
</div>
<div
data-part="rail"
tabIndex={0}
role="region"
aria-label={`${title}: горизонтальная лента`}
>
{cards.map((card) => (
<article key={card.title} data-part="card">
<span data-part="thumb" aria-hidden="true" />
<span data-part="name">{card.title}</span>
<span data-part="meta">{card.meta}</span>
</article>
))}
</div>
</div>
</>
)
}