Navigation
App Menubar
An application menubar: opening, Escape and closing a neighbouring menu all come from the HTML popover, not from your code.
- menubar
- menu
- popover
- no-js
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/menubar-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 "menubar-001" (App Menubar) 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/menubar-001.json
Registry item: https://vibeui.ru/r/menubar-001.json
Installs to: components/vibeui/menubar-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 application menubar: opening, Escape and closing a neighbouring menu all come from the HTML popover, not from your code.
An application menubar: sections with drop-down lists, shortcuts on the right and muted disabled items. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Menubar001 } from "@/components/vibeui/menubar-001"
<Menubar001 menus={[{ label: "File", items: [{ label: "Open", keys: "⌘O" }] }]} />
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-menubar-001-* palette — do not swap it for your theme tokens
- popover="auto": Escape, outside clicks and closing the neighbouring menu come from the browser
- a unique anchor name per button-menu pair — otherwise every menu lands under the first button
- the button staying highlighted while its menu is open
- the shortcut to the right of the item rather than inside its text
- disabled instead of hiding an unavailable item: vanishing items break the memory of a menu
## 6. You may change
- the menus array and their items
- the item handlers
- the accent through the accent prop
- the menubar height
## 7. Rules
- Without anchor positioning support the menu opens centred: check your target browsers.
- The component does not handle arrow keys between sections — Tab moves between them.
- A menubar belongs in an application, not on a landing page: a header with links is enough 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/menubar-001.jsonhttps://vibeui.ru/r/menubar-001.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-menubar-001-*. Серверный: хуков нет, состояние держит браузер. Каждое меню — popover="auto", поэтому Escape, клик мимо и закрытие соседа работают сами. Положение под своей кнопкой даёт CSS anchor positioning: имя якоря уникально для каждой пары и передаётся переменной.
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 Menubar001Menu = {
label: string
items: { label: string; keys?: string; disabled?: boolean }[]
}
export type Menubar001Props = Omit<
ComponentPropsWithoutRef<"div">,
"children"
> & {
menus?: Menubar001Menu[]
accent?: string
}
// Идея компонента: строка меню приложения на HTML popover. Открытие, закрытие
// по Escape и по клику мимо, а также взаимное закрытие соседних меню достаются
// от браузера — своя реализация потребовала бы состояния и глобального
// слушателя. Положение меню под своей кнопкой держит CSS anchor positioning:
// у каждой пары кнопка-меню собственное имя якоря.
const STYLES = `
:where([data-vibeui-block="menubar-001"]){
--vibeui-menubar-001-bg:oklch(1 0 0);
--vibeui-menubar-001-fg:oklch(0.24 0.014 265);
--vibeui-menubar-001-muted:oklch(0.58 0.014 265);
--vibeui-menubar-001-border:oklch(0.9 0.006 265);
--vibeui-menubar-001-hover:oklch(0.55 0.02 265 / 9%);
--vibeui-menubar-001-accent:oklch(0.55 0.2 262);
--vibeui-menubar-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="menubar-001"]{
display:flex;align-items:center;gap:0.125rem;
box-sizing:border-box;padding:0.25rem;
background:var(--vibeui-menubar-001-bg);
border:1px solid var(--vibeui-menubar-001-border);border-radius:0.625rem;
font-family:var(--vibeui-menubar-001-font);color:var(--vibeui-menubar-001-fg);
}
[data-vibeui-block="menubar-001"] [data-part="trigger"]{
appearance:none;border:0;background:none;cursor:pointer;
height:1.875rem;padding:0 0.625rem;border-radius:0.4375rem;
font:inherit;font-size:0.8125rem;color:inherit;
}
[data-vibeui-block="menubar-001"] [data-part="trigger"]:hover{background:var(--vibeui-menubar-001-hover)}
[data-vibeui-block="menubar-001"] [data-part="trigger"]:focus-visible{outline:2px solid var(--vibeui-menubar-001-accent);outline-offset:-2px}
/* Кнопка держит фон, пока её меню на экране: видно, какой раздел открыт. */
[data-vibeui-block="menubar-001"] [data-part="slot"]:has([data-part="menu"]:popover-open) [data-part="trigger"]{background:var(--vibeui-menubar-001-hover)}
[data-vibeui-block="menubar-001"] [data-part="menu"]{
position:fixed;inset:auto;margin:0;
min-width:11rem;padding:0.25rem;box-sizing:border-box;
background:var(--vibeui-menubar-001-bg);color:var(--vibeui-menubar-001-fg);
border:1px solid var(--vibeui-menubar-001-border);border-radius:0.625rem;
font-family:var(--vibeui-menubar-001-font);
box-shadow:0 16px 36px -18px oklch(0.2 0.03 265 / 45%);
}
/* У каждой пары кнопка-меню своё имя якоря: меню встаёт под свою кнопку. */
@supports (anchor-name: --a){
[data-vibeui-block="menubar-001"] [data-part="trigger"]{anchor-name:var(--vibeui-menubar-001-anchor)}
[data-vibeui-block="menubar-001"] [data-part="menu"]{
position-anchor:var(--vibeui-menubar-001-anchor);
position-area:bottom span-right;margin-top:0.375rem;
position-try-fallbacks:flip-block,flip-inline;
}
}
[data-vibeui-block="menubar-001"] [data-part="item"]{
display:flex;align-items:center;justify-content:space-between;gap:1.5rem;
width:100%;min-height:1.875rem;padding:0 0.5rem;box-sizing:border-box;
border-radius:0.4375rem;appearance:none;border:0;background:none;cursor:pointer;
font:inherit;font-size:0.8125rem;color:inherit;text-align:left;
}
[data-vibeui-block="menubar-001"] [data-part="item"]:hover:not(:disabled){background:var(--vibeui-menubar-001-hover)}
[data-vibeui-block="menubar-001"] [data-part="item"]:focus-visible{outline:2px solid var(--vibeui-menubar-001-accent);outline-offset:-2px}
[data-vibeui-block="menubar-001"] [data-part="item"]:disabled{color:var(--vibeui-menubar-001-muted);cursor:default}
[data-vibeui-block="menubar-001"] [data-part="keys"]{font-size:0.75rem;color:var(--vibeui-menubar-001-muted)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="menubar-001"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_MENUS: Menubar001Menu[] = [
{
label: "Файл",
items: [
{ label: "Новый проект", keys: "⌘N" },
{ label: "Открыть…", keys: "⌘O" },
{ label: "Сохранить", keys: "⌘S" },
{ label: "Восстановить версию", disabled: true },
],
},
{
label: "Правка",
items: [
{ label: "Отменить", keys: "⌘Z" },
{ label: "Повторить", keys: "⇧⌘Z" },
{ label: "Найти в проекте", keys: "⌘F" },
],
},
{
label: "Вид",
items: [
{ label: "Показать сетку" },
{ label: "Тёмная тема" },
{ label: "Во весь экран", keys: "F11" },
],
},
]
/**
* Строка меню приложения на HTML popover: открытие и закрытие от браузера.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Menubar001({
menus = DEFAULT_MENUS,
accent,
className,
style,
...props
}: Menubar001Props) {
const palette = {
...(accent ? { "--vibeui-menubar-001-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-menubar-001" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="menubar-001"
role="menubar"
className={className}
style={palette}
>
{menus.map((menu, index) => {
const id = `vibeui-menubar-001-${index}`
const anchor = {
"--vibeui-menubar-001-anchor": `--${id}`,
} as CSSProperties
return (
<span key={menu.label} data-part="slot" style={anchor}>
<button
type="button"
data-part="trigger"
role="menuitem"
popoverTarget={id}
>
{menu.label}
</button>
<div id={id} data-part="menu" popover="auto" role="menu">
{menu.items.map((item) => (
<button
key={item.label}
type="button"
data-part="item"
role="menuitem"
disabled={item.disabled}
>
{item.label}
{item.keys ? (
<span data-part="keys">{item.keys}</span>
) : null}
</button>
))}
</div>
</span>
)
})}
</div>
</>
)
}