Navigation

Grouped Nav

A menu with groups and sub-items and no JS at all: the groups are <details> elements and the group holding the current item is open from the start.

  • sidebar
  • groups
  • details
  • navigation

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/sidebar-004?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-004" (Grouped 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-004.json

Registry item: https://vibeui.ru/r/sidebar-004.json
Installs to: components/vibeui/sidebar-004.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 menu with groups and sub-items and no JS at all: the groups are <details> elements and the group holding the current item is open from the start.

Collapsible menu groups built on <details>: the current group is open and a collapsed one holding the active item is dotted. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Sidebar004 } from "@/components/vibeui/sidebar-004"

<Sidebar004
  activeLabel="Returns"
  groups={[
    { label: "Catalogue", children: [{ label: "Products", href: "/goods" }] },
    { label: "Sales", children: [{ label: "Returns", href: "/returns" }] },
  ]}
/>

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-004-* palette — do not swap it for your theme tokens
- <details> instead of hand-rolled disclosure: keyboard and in-page search work for free
- the group with the current item opened: the menu must not need a click to show where you are
- the dot on a collapsed group holding the active child — otherwise "where am I" is lost on collapse
- aria-current="page" on the active link, not just the fill
- the visible focus ring on the summary and the links

## 6. You may change
- the groups and sub-items through groups and the nested children
- the current item through activeLabel
- the accent colour through accent
- the column width through the root element's max-width

## 7. Rules
- The open state is not remembered across navigations: that is the price of having no client state.
- Several groups can be open at once — there is deliberately no accordion behaviour.
- The active item is matched by label text: identical labels in different groups both light up.
- 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-004.json
https://vibeui.ru/r/sidebar-004.json

Компонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-sidebar-004-*. Серверный: хуков нет, состояние раскрытия держит браузер через <details>. Атрибут open вычисляется на рендере из того, лежит ли активный пункт внутри группы: меню не должно требовать клика, чтобы показать, где пользователь находится. Свёрнутая группа с активным потомком помечена точкой в summary — после закрытия раздела текущее место иначе пропадает из виду. Галка нарисована бордюрами псевдоэлемента, маркер details скрыт.

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 Sidebar004Child = {
  label: string
  href?: string
}

export type Sidebar004Group = {
  label: string
  children: Sidebar004Child[]
}

export type Sidebar004Props = Omit<
  ComponentPropsWithoutRef<"nav">,
  "children"
> & {
  groups?: Sidebar004Group[]
  activeLabel?: string
  accent?: string
}

// Идея компонента: раскрывающиеся разделы без единой строки JS — каждая
// группа это <details>, а состояние держит браузер. Группа с текущим
// пунктом открыта заранее: меню не должно требовать клика, чтобы показать,
// где пользователь находится. Свёрнутая группа с активным потомком помечена
// точкой, иначе после закрытия раздела текущее место пропадает из виду.
const STYLES = `
:where([data-vibeui-block="sidebar-004"]){
--vibeui-sidebar-004-bg:oklch(1 0 0);
--vibeui-sidebar-004-fg:oklch(0.25 0.016 265);
--vibeui-sidebar-004-muted:oklch(0.55 0.014 265);
--vibeui-sidebar-004-border:oklch(0.91 0.006 265);
--vibeui-sidebar-004-accent:oklch(0.54 0.16 300);
--vibeui-sidebar-004-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="sidebar-004"]{
display:flex;flex-direction:column;gap:0.125rem;
width:100%;max-width:15rem;box-sizing:border-box;padding:0.625rem;
background:var(--vibeui-sidebar-004-bg);color:var(--vibeui-sidebar-004-fg);
border:1px solid var(--vibeui-sidebar-004-border);border-radius:0.875rem;
font-family:var(--vibeui-sidebar-004-font);
}
[data-vibeui-block="sidebar-004"] summary{
display:flex;align-items:center;gap:0.5rem;cursor:pointer;list-style:none;
padding:0.4375rem 0.5rem;border-radius:0.5rem;
font-size:0.875rem;font-weight:600;line-height:1.3;
}
[data-vibeui-block="sidebar-004"] summary::-webkit-details-marker{display:none}
[data-vibeui-block="sidebar-004"] summary:hover{background:oklch(0.55 0.02 265 / 7%)}
[data-vibeui-block="sidebar-004"] summary:focus-visible{outline:2px solid var(--vibeui-sidebar-004-accent);outline-offset:-2px}
/* Галка нарисована бордюрами: иконочный шрифт в самодостаточный файл не влезет. */
[data-vibeui-block="sidebar-004"] [data-part="chevron"]{
width:0.375rem;height:0.375rem;flex:none;
border-right:1.5px solid var(--vibeui-sidebar-004-muted);
border-bottom:1.5px solid var(--vibeui-sidebar-004-muted);
transform:rotate(-45deg);transition:transform .16s ease;
}
[data-vibeui-block="sidebar-004"] details[open] > summary [data-part="chevron"]{transform:rotate(45deg)}
/* Точка у свёрнутой группы: закрыв раздел, не теряем «где я». */
[data-vibeui-block="sidebar-004"] [data-part="mark"]{
margin-left:auto;width:0.375rem;height:0.375rem;border-radius:9999px;
background:var(--vibeui-sidebar-004-accent);
}
[data-vibeui-block="sidebar-004"] details[open] > summary [data-part="mark"]{display:none}
[data-vibeui-block="sidebar-004"] ul{
margin:0.0625rem 0 0.375rem 0.6875rem;padding:0 0 0 0.5rem;list-style:none;
display:flex;flex-direction:column;gap:0.0625rem;
border-left:1px solid var(--vibeui-sidebar-004-border);
}
[data-vibeui-block="sidebar-004"] a{
display:block;padding:0.3125rem 0.5rem;border-radius:0.375rem;
color:var(--vibeui-sidebar-004-muted);text-decoration:none;
font-size:0.8125rem;line-height:1.3;
}
[data-vibeui-block="sidebar-004"] a:hover{background:oklch(0.55 0.02 265 / 7%);color:var(--vibeui-sidebar-004-fg)}
[data-vibeui-block="sidebar-004"] a:focus-visible{outline:2px solid var(--vibeui-sidebar-004-accent);outline-offset:-2px}
[data-vibeui-block="sidebar-004"] a[aria-current="page"]{
color:var(--vibeui-sidebar-004-fg);font-weight:600;
background:color-mix(in oklab,var(--vibeui-sidebar-004-accent) 12%,transparent);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="sidebar-004"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_GROUPS: Sidebar004Group[] = [
  {
    label: "Каталог",
    children: [
      { label: "Товары", href: "#" },
      { label: "Категории", href: "#" },
      { label: "Бренды", href: "#" },
    ],
  },
  {
    label: "Продажи",
    children: [
      { label: "Заказы", href: "#" },
      { label: "Возвраты", href: "#" },
      { label: "Промокоды", href: "#" },
    ],
  },
  {
    label: "Настройки",
    children: [
      { label: "Доставка", href: "#" },
      { label: "Оплата", href: "#" },
    ],
  },
]

/**
 * Меню с разделами и подпунктами: группы на details, текущая раскрыта заранее.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Sidebar004({
  groups = DEFAULT_GROUPS,
  activeLabel = "Возвраты",
  accent,
  className,
  style,
  ...props
}: Sidebar004Props) {
  const palette = {
    ...(accent ? { "--vibeui-sidebar-004-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-sidebar-004" precedence="medium">
        {STYLES}
      </style>
      <nav
        {...props}
        data-vibeui-block="sidebar-004"
        aria-label="Разделы магазина"
        className={className}
        style={palette}
      >
        {groups.map((group) => {
          const holdsActive = group.children.some(
            (child) => child.label === activeLabel,
          )
          return (
            <details key={group.label} open={holdsActive}>
              <summary>
                <span data-part="chevron" aria-hidden="true" />
                {group.label}
                {holdsActive ? (
                  <span data-part="mark" aria-hidden="true" />
                ) : null}
              </summary>
              <ul>
                {group.children.map((child) => (
                  <li key={child.label}>
                    <a
                      href={child.href}
                      aria-current={
                        child.label === activeLabel ? "page" : undefined
                      }
                    >
                      {child.label}
                    </a>
                  </li>
                ))}
              </ul>
            </details>
          )
        })}
      </nav>
    </>
  )
}