Navigation
Inline Palette
A palette embedded in the page with groups and the full combobox contract: the field, the listbox and aria-activedescendant are all wired by hand.
- command
- palette
- combobox
- listbox
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/command-002?lang=en
Действия
- Новый компонент⌘N
- Пересобрать реестр⌘R
Переходы
- Открыть каталогG C
- Открыть настройкиG S
Вид
- Сменить тему⌘⇧L
- Показать сетку
↑↓ выбор · Enter запуск · Esc сброс
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 "command-002" (Inline Palette) 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/command-002.json
Registry item: https://vibeui.ru/r/command-002.json
Installs to: components/vibeui/command-002.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 palette embedded in the page with groups and the full combobox contract: the field, the listbox and aria-activedescendant are all wired by hand.
A command palette right on the page: grouped commands, substring search, arrows and Enter, Escape to clear. The combobox and listbox roles are declared explicitly. Zero dependencies, one file.
## 3. How to use it
import { Command002 } from "@/components/vibeui/command-002"
<Command002 commands={[{ label: "New component", group: "Actions", keys: "⌘N" }]} />
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-command-002-* palette — do not swap it for your theme tokens
- the role=combobox, role=listbox and aria-activedescendant trio: focus stays in the field, and without it the highlight is unannounced
- arrow order following the visible list rather than the source array — grouping changes it
- the same background for arrow highlight and hover: two different ones read as two positions
- aria-selected only on the active row: it marks the highlight, not a chosen value
- a clear empty answer instead of silence when nothing matches
## 6. You may change
- the commands array and the group names
- the field hint through the placeholder prop
- the palette name through the label prop
- the accent through the accent prop and the panel width
## 7. Rules
- The component does not bind the global ⌘K: the panel is inline, the handler is yours.
- There is deliberately no focus trap — the panel is not modal; use a native dialog for that.
- Search is a substring match on the label: fuzzy search and synonyms belong in your own filter.
- 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/command-002.jsonhttps://vibeui.ru/r/command-002.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-command-002-*. Клиентский: "use client" ради поиска и клавиатуры. Панель не модальная, поэтому весь ARIA-договор объявлен явно: корень role=dialog, поле role=combobox с aria-expanded и aria-controls, список role=listbox, группы role=group, строки role=option. Фокус остаётся в поле, подсветка передаётся через aria-activedescendant. Стрелки ходят по плоскому видимому порядку — после группировки он не совпадает с исходным массивом.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useId, useState } from "react"
import type {
ComponentPropsWithoutRef,
CSSProperties,
KeyboardEvent,
} from "react"
export type Command002Command = {
label: string
group: string
keys?: string
}
export type Command002Props = Omit<
ComponentPropsWithoutRef<"div">,
"children"
> & {
commands?: Command002Command[]
placeholder?: string
label?: string
accent?: string
}
// Идея компонента: палитра, встроенная в страницу, а не спрятанная в модалку.
// Отсюда весь ARIA-договор пишется руками: поле — combobox, список — listbox,
// строки — option, а подсветка передаётся через aria-activedescendant, потому
// что фокус остаётся в поле ввода и не уходит на строки. Стрелки ходят по
// плоскому видимому порядку: после группировки он не совпадает с исходным
// массивом, и индекс от исходного массива подсветил бы не ту строку.
const STYLES = `
:where([data-vibeui-block="command-002"]){
--vibeui-command-002-bg:oklch(1 0 0);
--vibeui-command-002-fg:oklch(0.23 0.014 265);
--vibeui-command-002-muted:oklch(0.57 0.014 265);
--vibeui-command-002-border:oklch(0.9 0.006 265);
--vibeui-command-002-accent:oklch(0.55 0.19 262);
--vibeui-command-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="command-002"]{
display:block;box-sizing:border-box;width:100%;max-width:24rem;
background:var(--vibeui-command-002-bg);color:var(--vibeui-command-002-fg);
border:1px solid var(--vibeui-command-002-border);border-radius:0.875rem;
box-shadow:0 18px 40px -28px oklch(0.2 0.03 265 / 60%);
font-family:var(--vibeui-command-002-font);overflow:hidden;
}
[data-vibeui-block="command-002"] [data-part="field"]{
display:flex;align-items:center;gap:0.5rem;
padding:0 0.875rem;border-bottom:1px solid var(--vibeui-command-002-border);
}
[data-vibeui-block="command-002"] [data-part="glyph"]{flex:none;color:var(--vibeui-command-002-muted);font-size:0.875rem}
[data-vibeui-block="command-002"] input{
flex:1;min-width:0;height:2.875rem;
appearance:none;border:0;background:none;color:inherit;
font:inherit;font-size:0.9375rem;outline:none;
}
[data-vibeui-block="command-002"] [data-part="field"]:focus-within{box-shadow:inset 0 -2px 0 0 var(--vibeui-command-002-accent)}
[data-vibeui-block="command-002"] [data-part="list"]{
list-style:none;margin:0;padding:0.3125rem;max-height:15rem;overflow-y:auto;
}
[data-vibeui-block="command-002"] [data-part="list"] [data-part="list"]{padding:0;max-height:none;overflow:visible}
[data-vibeui-block="command-002"] [data-part="group"]{
padding:0.5rem 0.5625rem 0.25rem;margin:0;
font-size:0.6875rem;font-weight:700;letter-spacing:0.05em;text-transform:uppercase;
color:var(--vibeui-command-002-muted);
}
[data-vibeui-block="command-002"] [data-part="row"]{
display:flex;align-items:center;gap:0.75rem;
padding:0.4375rem 0.5625rem;border-radius:0.5rem;cursor:pointer;
font-size:0.875rem;
}
/* Подсветка одна на клавиатуру и мышь: две разные читаются как две позиции. */
[data-vibeui-block="command-002"] [data-part="row"]:hover,
[data-vibeui-block="command-002"] [data-part="row"][aria-selected="true"]{
background:color-mix(in oklab,var(--vibeui-command-002-accent) 12%,transparent);
}
[data-vibeui-block="command-002"] [data-part="row"] kbd{
margin-left:auto;
border:1px solid var(--vibeui-command-002-border);border-bottom-width:2px;border-radius:0.3125rem;
padding:0 0.3125rem;font:inherit;font-size:0.6875rem;color:var(--vibeui-command-002-muted);
}
[data-vibeui-block="command-002"] [data-part="empty"]{
margin:0;padding:1.25rem 0.875rem;font-size:0.875rem;color:var(--vibeui-command-002-muted);
}
[data-vibeui-block="command-002"] [data-part="foot"]{
display:flex;align-items:center;gap:0.75rem;
padding:0.4375rem 0.875rem;border-top:1px solid var(--vibeui-command-002-border);
font-size:0.6875rem;color:var(--vibeui-command-002-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="command-002"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_COMMANDS: Command002Command[] = [
{ label: "Новый компонент", group: "Действия", keys: "⌘N" },
{ label: "Пересобрать реестр", group: "Действия", keys: "⌘R" },
{ label: "Открыть каталог", group: "Переходы", keys: "G C" },
{ label: "Открыть настройки", group: "Переходы", keys: "G S" },
{ label: "Сменить тему", group: "Вид", keys: "⌘⇧L" },
{ label: "Показать сетку", group: "Вид" },
]
/**
* Встроенная командная палитра с группами и полным договором combobox +
* listbox. Один файл, ноль зависимостей, собственная палитра.
*/
export function Command002({
commands = DEFAULT_COMMANDS,
placeholder = "Команда или переход…",
label = "Командная палитра",
accent,
className,
style,
...props
}: Command002Props) {
const [query, setQuery] = useState("")
const [active, setActive] = useState(0)
const [chosen, setChosen] = useState<string | null>(null)
const listId = useId()
const rowId = useId()
const needle = query.trim().toLowerCase()
const found = commands.filter((command) =>
command.label.toLowerCase().includes(needle),
)
const groups = found.reduce<Record<string, Command002Command[]>>(
(all, command) => {
all[command.group] = all[command.group]
? [...all[command.group], command]
: [command]
return all
},
{},
)
const ordered = Object.values(groups).flat()
const current = ordered[Math.min(active, ordered.length - 1)]
const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
event.preventDefault()
if (ordered.length === 0) return
const step = event.key === "ArrowDown" ? 1 : -1
setActive((index) => (index + step + ordered.length) % ordered.length)
return
}
if (event.key === "Enter" && current) {
event.preventDefault()
setChosen(current.label)
return
}
if (event.key === "Escape") {
event.preventDefault()
setQuery("")
setActive(0)
}
}
const palette = {
...(accent ? { "--vibeui-command-002-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-command-002" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="command-002"
className={className}
style={palette}
role="dialog"
aria-label={label}
>
<div data-part="field">
<span data-part="glyph" aria-hidden="true">
⌕
</span>
<input
type="text"
role="combobox"
aria-expanded={ordered.length > 0}
aria-controls={listId}
aria-autocomplete="list"
aria-activedescendant={
current ? `${rowId}-${ordered.indexOf(current)}` : undefined
}
aria-label={placeholder}
placeholder={placeholder}
value={query}
onChange={(event) => {
setQuery(event.target.value)
setActive(0)
}}
onKeyDown={onKeyDown}
/>
</div>
{ordered.length === 0 ? (
<p data-part="empty">Ничего не нашлось. Попробуйте другое слово.</p>
) : (
<ul id={listId} data-part="list" role="listbox" aria-label={label}>
{Object.entries(groups).map(([group, rows]) => (
<li key={group} role="presentation">
<p data-part="group">{group}</p>
<ul data-part="list" role="group" aria-label={group}>
{rows.map((command) => (
<li
key={command.label}
id={`${rowId}-${ordered.indexOf(command)}`}
data-part="row"
role="option"
aria-selected={current?.label === command.label}
onClick={() => setChosen(command.label)}
>
{command.label}
{command.keys ? <kbd>{command.keys}</kbd> : null}
</li>
))}
</ul>
</li>
))}
</ul>
)}
<p data-part="foot" role="status">
{chosen
? `Выполнено: ${chosen}`
: "↑↓ выбор · Enter запуск · Esc сброс"}
</p>
</div>
</>
)
}