Command
Command menu for real-time filtering and quick actions, inline or inside a dialog.
A searchable command palette with real-time filtering and keyboard navigation. Clicking an item or pressing Enter emits an execute event for your application to handle. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<shadcn-style-scope id="command-scope" class="contents">
<div
class="w-full max-w-sm rounded-[var(--pui-radius-3xl)] border border-border bg-popover shadow-md"
>
<shadcn-command-root id="command-root">
<shadcn-command-input-wrapper>
<shadcn-input-shell id="command-shell">
<shadcn-command-input
id="command-input"
></shadcn-command-input>
</shadcn-input-shell>
</shadcn-command-input-wrapper>
<shadcn-command-content>
<div
class="px-2 py-1.5 text-xs font-medium text-muted-foreground"
aria-hidden="true"
>
Suggestions
</div>
<shadcn-command-item data-cmd="calendar">
Calendar
</shadcn-command-item>
<shadcn-command-item data-cmd="search-emoji">
Search Emoji
</shadcn-command-item>
<shadcn-command-item data-cmd="calculator">
Calculator
</shadcn-command-item>
<div class="my-1 h-px bg-border" role="separator"></div>
<div
class="px-2 py-1.5 text-xs font-medium text-muted-foreground"
aria-hidden="true"
>
Settings
</div>
<shadcn-command-item data-cmd="profile">
<span>Profile</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘P
</span>
</shadcn-command-item>
<shadcn-command-item data-cmd="billing">
<span>Billing</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘B
</span>
</shadcn-command-item>
<shadcn-command-item data-cmd="settings">
<span>Settings</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘S
</span>
</shadcn-command-item>
<shadcn-command-empty>
No results found.
</shadcn-command-empty>
</shadcn-command-content>
</shadcn-command-root>
</div>
</shadcn-style-scope>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#command-scope'), {
styleProfile: 'rhea',
});
setElementProps(document.querySelector('#command-shell'), {
focusIndicator: 'none',
});
setElementProps(document.querySelector('#command-input'), {
placeholder: 'Type a command or search...',
a11yLabel: 'Type a command or search',
});
const root = document.querySelector('#command-root');
setElementProps(root, { a11yLabel: 'Command menu' });
root.addEventListener('execute', (event) =>
console.log('execute', event.detail)
);
</script>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases (@proto.ui/prototypes-shadcn/command).
import { commandRoot, commandInputWrapper, commandInput, commandContent, commandItem, commandEmpty, commandDialogContent, commandDialogMask,} from '@proto.ui/prototypes-shadcn/command';import { inputShell } from '@proto.ui/prototypes-shadcn/input-shell';Composition
Section titled “Composition”CommandRoot├── CommandInputWrapper│ └── InputShell (focusIndicator="none")│ └── CommandInput└── CommandContent ├── CommandItem └── CommandEmpty- Inline by default:
defaultOpendefaults totrue. Typing filters matching items without executing anything; activating an item via click orEnteremitsexecute. - Command dialog: Compose
DialogRoot,DialogTrigger,CommandDialogMask, andCommandDialogContentwith matchingenterDurationandleaveDurationfor the selected profile (100for Rhea,200for New York). - Filtering and keyboard: Matches case- and diacritic-insensitively over
textValueandkeywords, or setfilter={false}for caller-filtered children. Focus remains in the input during arrow navigation and IME composition never triggers execution.
Examples
Section titled “Examples”Command Dialog
Section titled “Command Dialog”Compose Command inside a modal Dialog using CommandDialogMask and CommandDialogContent.
<shadcn-style-scope id="dialog-scope" class="contents">
<shadcn-dialog-root>
<shadcn-dialog-trigger>Open Menu</shadcn-dialog-trigger>
<shadcn-command-dialog-mask
id="cmd-mask"
></shadcn-command-dialog-mask>
<shadcn-command-dialog-content id="cmd-dialog">
<shadcn-dialog-title class="sr-only">
Command Palette
</shadcn-dialog-title>
<shadcn-dialog-description class="sr-only">
Search for a command to run.
</shadcn-dialog-description>
<shadcn-command-root id="cmd-root">
<shadcn-command-input-wrapper>
<shadcn-input-shell id="cmd-shell">
<shadcn-command-input
id="cmd-input"
></shadcn-command-input>
</shadcn-input-shell>
</shadcn-command-input-wrapper>
<shadcn-command-content>
<shadcn-command-item>Calendar</shadcn-command-item>
<shadcn-command-item>Search Emoji</shadcn-command-item>
<shadcn-command-item>Calculator</shadcn-command-item>
<shadcn-command-empty>
No results found.
</shadcn-command-empty>
</shadcn-command-content>
</shadcn-command-root>
</shadcn-command-dialog-content>
</shadcn-dialog-root>
</shadcn-style-scope>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#dialog-scope'), {
styleProfile: 'rhea',
});
setElementProps(document.querySelector('#cmd-mask'), {
enterDuration: 100,
leaveDuration: 100,
});
setElementProps(document.querySelector('#cmd-dialog'), {
enterDuration: 100,
leaveDuration: 100,
});
setElementProps(document.querySelector('#cmd-shell'), {
focusIndicator: 'none',
});
setElementProps(document.querySelector('#cmd-input'), {
placeholder: 'Type a command or search...',
});
</script>Shortcuts & Keywords
Section titled “Shortcuts & Keywords”Display trailing keyboard hints inside items and match synonyms via keywords.
<shadcn-style-scope id="shortcuts-scope" class="contents">
<div
class="w-full max-w-sm rounded-[var(--pui-radius-3xl)] border border-border bg-popover shadow-md"
>
<shadcn-command-root>
<shadcn-command-input-wrapper>
<shadcn-input-shell>
<shadcn-command-input></shadcn-command-input>
</shadcn-input-shell>
</shadcn-command-input-wrapper>
<shadcn-command-content>
<shadcn-command-item>
<span>Profile</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘P
</span>
</shadcn-command-item>
<shadcn-command-item>
<span>Billing</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘B
</span>
</shadcn-command-item>
<shadcn-command-item>
<span>Settings</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘S
</span>
</shadcn-command-item>
<shadcn-command-item>
<span>Keyboard Shortcuts</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘K
</span>
</shadcn-command-item>
<shadcn-command-empty>
No matching shortcuts.
</shadcn-command-empty>
</shadcn-command-content>
</shadcn-command-root>
</div>
</shadcn-style-scope>Groups & Disabled Items
Section titled “Groups & Disabled Items”Organize workspace actions into sections with separators and non-executable disabled entries.
<shadcn-style-scope id="command-scope" class="contents">
<div
class="w-full max-w-sm rounded-[var(--pui-radius-3xl)] border border-border bg-popover shadow-md"
>
<shadcn-command-root id="command-root">
<shadcn-command-input-wrapper>
<shadcn-input-shell id="command-shell">
<shadcn-command-input
id="command-input"
></shadcn-command-input>
</shadcn-input-shell>
</shadcn-command-input-wrapper>
<shadcn-command-content>
<div
class="px-2 py-1.5 text-xs font-medium text-muted-foreground"
aria-hidden="true"
>
Suggestions
</div>
<shadcn-command-item data-cmd="calendar">
Calendar
</shadcn-command-item>
<shadcn-command-item data-cmd="search-emoji">
Search Emoji
</shadcn-command-item>
<shadcn-command-item data-cmd="calculator">
Calculator
</shadcn-command-item>
<div class="my-1 h-px bg-border" role="separator"></div>
<div
class="px-2 py-1.5 text-xs font-medium text-muted-foreground"
aria-hidden="true"
>
Settings
</div>
<shadcn-command-item data-cmd="profile">
<span>Profile</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘P
</span>
</shadcn-command-item>
<shadcn-command-item data-cmd="billing">
<span>Billing</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘B
</span>
</shadcn-command-item>
<shadcn-command-item data-cmd="settings">
<span>Settings</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘S
</span>
</shadcn-command-item>
<shadcn-command-empty>
No results found.
</shadcn-command-empty>
</shadcn-command-content>
</shadcn-command-root>
</div>
</shadcn-style-scope>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#command-scope'), {
styleProfile: 'rhea',
});
setElementProps(document.querySelector('#command-shell'), {
focusIndicator: 'none',
});
setElementProps(document.querySelector('#command-input'), {
placeholder: 'Type a command or search...',
a11yLabel: 'Type a command or search',
});
const root = document.querySelector('#command-root');
setElementProps(root, { a11yLabel: 'Command menu' });
root.addEventListener('execute', (event) =>
console.log('execute', event.detail)
);
</script>Scrollable
Section titled “Scrollable”Browse many categorized commands inside the bounded scrollable list viewport.
<shadcn-style-scope id="command-scope" class="contents">
<div
class="w-full max-w-sm rounded-[var(--pui-radius-3xl)] border border-border bg-popover shadow-md"
>
<shadcn-command-root id="command-root">
<shadcn-command-input-wrapper>
<shadcn-input-shell id="command-shell">
<shadcn-command-input
id="command-input"
></shadcn-command-input>
</shadcn-input-shell>
</shadcn-command-input-wrapper>
<shadcn-command-content>
<div
class="px-2 py-1.5 text-xs font-medium text-muted-foreground"
aria-hidden="true"
>
Suggestions
</div>
<shadcn-command-item data-cmd="calendar">
Calendar
</shadcn-command-item>
<shadcn-command-item data-cmd="search-emoji">
Search Emoji
</shadcn-command-item>
<shadcn-command-item data-cmd="calculator">
Calculator
</shadcn-command-item>
<div class="my-1 h-px bg-border" role="separator"></div>
<div
class="px-2 py-1.5 text-xs font-medium text-muted-foreground"
aria-hidden="true"
>
Settings
</div>
<shadcn-command-item data-cmd="profile">
<span>Profile</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘P
</span>
</shadcn-command-item>
<shadcn-command-item data-cmd="billing">
<span>Billing</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘B
</span>
</shadcn-command-item>
<shadcn-command-item data-cmd="settings">
<span>Settings</span>
<span
class="ml-auto font-mono text-xs text-muted-foreground"
>
⌘S
</span>
</shadcn-command-item>
<shadcn-command-empty>
No results found.
</shadcn-command-empty>
</shadcn-command-content>
</shadcn-command-root>
</div>
</shadcn-style-scope>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#command-scope'), {
styleProfile: 'rhea',
});
setElementProps(document.querySelector('#command-shell'), {
focusIndicator: 'none',
});
setElementProps(document.querySelector('#command-input'), {
placeholder: 'Type a command or search...',
a11yLabel: 'Type a command or search',
});
const root = document.querySelector('#command-root');
setElementProps(root, { a11yLabel: 'Command menu' });
root.addEventListener('execute', (event) =>
console.log('execute', event.detail)
);
</script>Pass value, inputValue, or open to control each state independently. Use styleProfile directly or via an outer shadcn-style-scope to select among all 9 built-in styles.
| Prop | Type | Default |
|---|---|---|
value | string | — |
defaultValue | string | '' |
inputValue | string | — |
defaultInputValue | string | '' |
open | boolean | — |
defaultOpen | boolean | true |
disabled | boolean | false |
readOnly | boolean | false |
filter | boolean | true |
loop | boolean | true |
a11yLabel | string | '' |
styleProfile | ShadcnStyleId | 'new-york-v4' |
presentation | 'default' 'menu' | 'default' |
Other Parts & Events
Section titled “Other Parts & Events”- InputWrapper: Passive input container supporting
styleProfileandpresentation('default' | 'menu'). - Input:
placeholder,a11yLabel, andnamedefault to''. - Content:
side="bottom",align="start",sideOffset={4},collisionPadding={8}. - Item:
value,textValue, andkeywordsdefault to'';disableddefaults tofalse. - Empty: No props; reflects the live match count.
- DialogContent / DialogMask: Requires
enterDuration: numberandleaveDuration: number;DialogContentalso acceptsstyleProfileandpresentation. - Events:
Rootemitsexecute,valueChange,inputValueChange, andopenChange.