Breadcrumb
Collapsing Breadcrumb
A breadcrumb that collapses in the middle rather than truncating at the end: the root and the current level always survive.
- breadcrumb
- navigation
- path
- aria
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/breadcrumb-001?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 "breadcrumb-001" (Collapsing Breadcrumb) 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/breadcrumb-001.json
Registry item: https://vibeui.ru/r/breadcrumb-001.json
Installs to: components/vibeui/breadcrumb-001.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 breadcrumb that collapses in the middle rather than truncating at the end: the root and the current level always survive.
A breadcrumb that collapses its middle: on a long path the root, an ellipsis and the last levels remain. The current level is not a link and carries aria-current. The separators are drawn in CSS. Zero dependencies, one file, its own palette, no client JS.
## 3. How to use it
import { Breadcrumb001 } from "@/components/vibeui/breadcrumb-001"
<Breadcrumb001
items={[
{ label: "Projects", href: "/projects" },
{ label: "Studio site", href: "/projects/studio" },
{ label: "Home" },
]}
/>
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-breadcrumb-001-* palette — do not swap it for your theme tokens (text-muted-foreground and the like)
- collapsing the middle specifically: truncating the end hides the current level, the one thing that says where the user is
- the <nav> + <ol> semantics with a label: this is a list of levels, not a pile of links
- the current level as text with aria-current="page" rather than a link to itself
- aria-hidden on the separators: a screen reader should not read "arrow" between levels
- the ellipsis as a non-interactive mark: a menu that expands it is a different component
- the <style> block inside the component — it holds the palette, the separators and the label truncation
## 6. You may change
- the items array: labels and hrefs; the last item needs no href
- maxVisible — how many levels show before collapsing
- the accent through the accent prop — it colours the focus ring
- outer spacing through className
## 7. Rules
- A breadcrumb shows position in the site structure, not browsing history. Do not build it from the history stack.
- Do not make it the only way back on mobile: the platform back gesture already covers that.
- The collapse counts levels, not real width. For very long labels lower maxVisible.
- 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/breadcrumb-001.jsonhttps://vibeui.ru/r/breadcrumb-001.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-breadcrumb-001-*. Разметка семантическая: <nav> с подписью, внутри <ol> — порядок уровней имеет значение. Текущий уровень не ссылка и помечен aria-current="page". Разделитель — грань квадрата, повёрнутая на 45°, поэтому шрифтовые символы и иконки не нужны. Свёртка считается по maxVisible: первый уровень, многоточие, затем последние.
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 Breadcrumb001Item = {
label: string
href?: string
}
export type Breadcrumb001Props = Omit<
ComponentPropsWithoutRef<"nav">,
"children"
> & {
items?: Breadcrumb001Item[]
/** Сколько уровней показывать целиком. Середина сворачивается в многоточие. */
maxVisible?: number
accent?: string
}
// Идея компонента: длинный путь сворачивается посередине, а не обрезается
// с конца. Первый и последний уровни — самые нужные: откуда пришли и где
// находимся; их и оставляем, а середину прячем за многоточием.
const STYLES = `
:where([data-vibeui-block="breadcrumb-001"]){
--vibeui-breadcrumb-001-surface:oklch(1 0 0);
--vibeui-breadcrumb-001-surface-border:oklch(0.91 0.006 265);
--vibeui-breadcrumb-001-fg:oklch(0.28 0.016 265);
--vibeui-breadcrumb-001-muted:oklch(0.55 0.014 265);
--vibeui-breadcrumb-001-accent:oklch(0.55 0.2 262);
--vibeui-breadcrumb-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Собственная подложка: крошки — это текст, и на тёмной странице
он обязан читаться без правки палитры проекта. */
[data-vibeui-block="breadcrumb-001"]{
box-sizing:border-box;padding:0.5rem 0.75rem;
background:var(--vibeui-breadcrumb-001-surface);
border:1px solid var(--vibeui-breadcrumb-001-surface-border);border-radius:0.625rem;
font-family:var(--vibeui-breadcrumb-001-font);font-size:0.8125rem;line-height:1.4;
}
[data-vibeui-block="breadcrumb-001"] ol{
display:flex;flex-wrap:wrap;align-items:center;gap:0.375rem;
margin:0;padding:0;list-style:none;
}
[data-vibeui-block="breadcrumb-001"] li{display:flex;align-items:center;gap:0.375rem;min-width:0}
[data-vibeui-block="breadcrumb-001"] a{
color:var(--vibeui-breadcrumb-001-muted);text-decoration:none;
border-radius:0.25rem;
transition:color .16s ease;
}
[data-vibeui-block="breadcrumb-001"] a:hover{color:var(--vibeui-breadcrumb-001-fg)}
[data-vibeui-block="breadcrumb-001"] a:focus-visible{outline:2px solid var(--vibeui-breadcrumb-001-accent);outline-offset:2px}
/* Текущий уровень — не ссылка: на страницу, где стоишь, не переходят. */
[data-vibeui-block="breadcrumb-001"] [data-part="current"]{
color:var(--vibeui-breadcrumb-001-fg);font-weight:500;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="breadcrumb-001"] [data-part="ellipsis"]{color:var(--vibeui-breadcrumb-001-muted);letter-spacing:0.05em}
/* Разделитель — грань квадрата: одна фигура вместо шрифтового символа. */
[data-vibeui-block="breadcrumb-001"] [data-part="sep"]{
width:0.3125rem;height:0.3125rem;flex:none;
border-right:1.5px solid var(--vibeui-breadcrumb-001-muted);
border-top:1.5px solid var(--vibeui-breadcrumb-001-muted);
transform:rotate(45deg);opacity:.7;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="breadcrumb-001"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_ITEMS: Breadcrumb001Item[] = [
{ label: "Проекты", href: "#" },
{ label: "Студия «Полёт»", href: "#" },
{ label: "Сайт студии", href: "#" },
{ label: "Страницы", href: "#" },
{ label: "Главная" },
]
/**
* Хлебные крошки, сворачивающиеся посередине.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Breadcrumb001({
items = DEFAULT_ITEMS,
maxVisible = 3,
accent,
className,
style,
...props
}: Breadcrumb001Props) {
const palette = {
...(accent ? { "--vibeui-breadcrumb-001-accent": accent } : null),
...style,
} as CSSProperties
const collapsed = items.length > maxVisible
const visible = collapsed
? [items[0], ...items.slice(items.length - (maxVisible - 1))]
: items
const ellipsisAfter = collapsed ? 0 : -1
return (
<>
<style href="vibeui-breadcrumb-001" precedence="medium">
{STYLES}
</style>
<nav
{...props}
data-vibeui-block="breadcrumb-001"
aria-label="Хлебные крошки"
className={className}
style={palette}
>
<ol>
{visible.map((item, index) => {
const last = index === visible.length - 1
return (
<li key={`${item.label}-${index}`}>
{item.href && !last ? (
<a href={item.href}>{item.label}</a>
) : (
<span
data-part="current"
aria-current={last ? "page" : undefined}
>
{item.label}
</span>
)}
{index === ellipsisAfter ? (
<>
<span data-part="sep" aria-hidden="true" />
<span data-part="ellipsis" aria-hidden="true">
…
</span>
</>
) : null}
{last ? null : <span data-part="sep" aria-hidden="true" />}
</li>
)
})}
</ol>
</nav>
</>
)
}