Navigation
App Sidebar Nav
An app sidebar: sections, counts and a current item marked by a bar at the edge rather than text colour alone.
- sidebar
- navigation
- app shell
- menu
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/sidebar-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 "sidebar-001" (App Sidebar Nav) 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/sidebar-001.json
Registry item: https://vibeui.ru/r/sidebar-001.json
Installs to: components/vibeui/sidebar-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
An app sidebar: sections, counts and a current item marked by a bar at the edge rather than text colour alone.
A vertical app menu: titled sections, link items, counts on the right and a current item marked by an edge bar and a solid background. In a long list the current place is found at a glance. Zero dependencies, one file, its own palette, no client JS.
## 3. How to use it
import { Sidebar001 } from "@/components/vibeui/sidebar-001"
<Sidebar001
activeLabel="Pages"
sections={[
{ title: "Project", items: [{ label: "Overview", href: "/" }, { label: "Pages", href: "/pages", count: 12 }] },
]}
/>
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-sidebar-001-* palette — do not swap it for your theme tokens (bg-sidebar, bg-accent and the like)
- the double marking of the active item: the edge bar plus the background — text colour alone loses the active section
- aria-current="page" on the current item: it is how a screen reader finds it
- the <nav> + <ul> semantics: a menu is a list of links, not a pile of divs
- the section titles as labels rather than links — nobody navigates to them
- tabular-nums on the counts, otherwise the numbers jitter the right edge
- the <style> block inside the component — it holds the palette, the layout and the active marking
## 6. You may change
- the sections array: section titles, items, hrefs and counts
- activeLabel — the current item's label; in a real app feed it from the router
- the accent through the accent prop — it colours the bar and the focus ring
- max width and outer spacing through className
## 7. Rules
- The component knows nothing about routes. The caller decides the active item: compare the router path and pass the label.
- Do not nest deeper than one level: a tree needs a different component.
- A count means something needing attention — unread, failing. The total number of items does not belong there.
- 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/sidebar-001.jsonhttps://vibeui.ru/r/sidebar-001.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-sidebar-001-*. Разметка семантическая: <nav> с подписью, внутри разделы с заголовками и списки <ul>. Активный пункт определяется сравнением подписи с activeLabel и получает aria-current="page", плотный фон и полосу через ::before. Счётчик — необязательное число справа с tabular-nums.
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 Sidebar001Item = {
label: string
href?: string
/** Число справа: непрочитанные, черновики, ошибки. */
count?: number
}
export type Sidebar001Section = {
title?: string
items: Sidebar001Item[]
}
export type Sidebar001Props = Omit<
ComponentPropsWithoutRef<"nav">,
"children"
> & {
sections?: Sidebar001Section[]
/** Подпись активного пункта. Сравнивается по тексту, а не по адресу. */
activeLabel?: string
accent?: string
}
// Идея компонента: активный пункт отмечен полосой у левого края и плотным
// фоном, а не только цветом текста. В длинном списке разделов взгляд находит
// текущее место сразу, и метка не исчезает при смене темы.
const STYLES = `
:where([data-vibeui-block="sidebar-001"]){
--vibeui-sidebar-001-fg:oklch(0.26 0.016 265);
--vibeui-sidebar-001-muted:oklch(0.55 0.014 265);
--vibeui-sidebar-001-bg:oklch(0.985 0.002 265);
--vibeui-sidebar-001-border:oklch(0.91 0.006 265);
--vibeui-sidebar-001-hover:oklch(0.55 0.02 265 / 7%);
--vibeui-sidebar-001-active:oklch(0.55 0.02 265 / 12%);
--vibeui-sidebar-001-accent:oklch(0.55 0.2 262);
--vibeui-sidebar-001-radius:0.5rem;
--vibeui-sidebar-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="sidebar-001"]{
display:flex;flex-direction:column;gap:1.125rem;
width:100%;max-width:15rem;box-sizing:border-box;
padding:0.875rem 0.75rem;
border:1px solid var(--vibeui-sidebar-001-border);
border-radius:0.875rem;
background:var(--vibeui-sidebar-001-bg);color:var(--vibeui-sidebar-001-fg);
font-family:var(--vibeui-sidebar-001-font);
}
[data-vibeui-block="sidebar-001"] [data-part="section"]{display:flex;flex-direction:column;gap:0.125rem}
[data-vibeui-block="sidebar-001"] [data-part="title"]{
padding:0 0.5rem 0.375rem;
font-size:0.6875rem;font-weight:600;letter-spacing:0.07em;text-transform:uppercase;
color:var(--vibeui-sidebar-001-muted);
}
[data-vibeui-block="sidebar-001"] ul{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:0.125rem}
[data-vibeui-block="sidebar-001"] a{
position:relative;display:flex;align-items:center;justify-content:space-between;gap:0.5rem;
padding:0.4375rem 0.5rem;border-radius:var(--vibeui-sidebar-001-radius);
color:var(--vibeui-sidebar-001-muted);text-decoration:none;
font-size:0.875rem;line-height:1.35;
transition:background-color .16s ease,color .16s ease;
}
[data-vibeui-block="sidebar-001"] a:hover{background:var(--vibeui-sidebar-001-hover);color:var(--vibeui-sidebar-001-fg)}
[data-vibeui-block="sidebar-001"] a:focus-visible{outline:2px solid var(--vibeui-sidebar-001-accent);outline-offset:-2px}
[data-vibeui-block="sidebar-001"] a[aria-current="page"]{
background:var(--vibeui-sidebar-001-active);color:var(--vibeui-sidebar-001-fg);font-weight:500;
}
/* Полоса у края: активный пункт отличается не только цветом. */
[data-vibeui-block="sidebar-001"] a[aria-current="page"]::before{
content:"";position:absolute;left:-0.75rem;top:0.3125rem;bottom:0.3125rem;
width:2px;border-radius:0 2px 2px 0;background:var(--vibeui-sidebar-001-accent);
}
[data-vibeui-block="sidebar-001"] [data-part="count"]{
flex:none;font-size:0.75rem;color:var(--vibeui-sidebar-001-muted);
font-variant-numeric:tabular-nums;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="sidebar-001"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_SECTIONS: Sidebar001Section[] = [
{
title: "Проект",
items: [
{ label: "Обзор", href: "#" },
{ label: "Страницы", href: "#", count: 12 },
{ label: "Медиа", href: "#" },
],
},
{
title: "Публикация",
items: [
{ label: "Домены", href: "#" },
{ label: "История", href: "#", count: 3 },
{ label: "Настройки", href: "#" },
],
},
]
/**
* Вертикальная навигация приложения с отмеченным текущим разделом.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Sidebar001({
sections = DEFAULT_SECTIONS,
activeLabel = "Страницы",
accent,
className,
style,
...props
}: Sidebar001Props) {
const palette = {
...(accent ? { "--vibeui-sidebar-001-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-sidebar-001" precedence="medium">
{STYLES}
</style>
<nav
{...props}
data-vibeui-block="sidebar-001"
aria-label="Разделы проекта"
className={className}
style={palette}
>
{sections.map((section, index) => (
<div data-part="section" key={section.title ?? index}>
{section.title ? (
<span data-part="title">{section.title}</span>
) : null}
<ul>
{section.items.map((item) => (
<li key={item.label}>
<a
href={item.href}
aria-current={
item.label === activeLabel ? "page" : undefined
}
>
{item.label}
{item.count === undefined ? null : (
<span data-part="count">{item.count}</span>
)}
</a>
</li>
))}
</ul>
</div>
))}
</nav>
</>
)
}