Command
A Duostrap searchable command palette preserving classic gradients and focus glow.
Duostrap Command pairs classic 2.3.2 input focus glow and gradient menu highlights with real-time filtering, keyboard navigation, and dialog composition.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="w-full max-w-sm">
<duostrap-command-root id="command-root">
<duostrap-command-input
id="command-input"
></duostrap-command-input>
<duostrap-command-content>
<duostrap-command-item>Calendar</duostrap-command-item>
<duostrap-command-item>Search Emoji</duostrap-command-item>
<duostrap-command-item>Calculator</duostrap-command-item>
<duostrap-command-item>
<span>Profile</span>
<span class="ml-auto font-mono text-xs">⌘P</span>
</duostrap-command-item>
<duostrap-command-item>
<span>Billing</span>
<span class="ml-auto font-mono text-xs">⌘B</span>
</duostrap-command-item>
<duostrap-command-item>
<span>Settings</span>
<span class="ml-auto font-mono text-xs">⌘S</span>
</duostrap-command-item>
<duostrap-command-empty>
No results found.
</duostrap-command-empty>
</duostrap-command-content>
</duostrap-command-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
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-duostrap/command).
import { commandRoot, commandInput, commandContent, commandItem, commandEmpty,} from '@proto.ui/prototypes-duostrap/command';Composition
Section titled “Composition”CommandRoot├── CommandInput└── CommandContent ├── CommandItem └── CommandEmpty- Classic styling: Retains the 30px input height,
#52a8ecfocus glow, 6px dropdown panel shadow, and#08c -> #0077b3active highlight gradient with a bounded300pxscrollable list. - Filtering and execution: Matches
textValueandkeywordscase- and diacritic-insensitively, or setfilter={false}for external filtering. PressingEnteror clicking an item emitsexecute. - Keyboard and IME: Focus stays in
Inputduring arrow navigation, IME composition never triggers selection, and disabled or duplicate-valued items cannot execute.
Examples
Section titled “Examples”Command in Dialog
Section titled “Command in Dialog”Compose Command inside a classic Duostrap modal dialog.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<duostrap-dialog-root>
<duostrap-dialog-trigger>Open Menu</duostrap-dialog-trigger>
<duostrap-dialog-mask></duostrap-dialog-mask>
<duostrap-dialog-content>
<duostrap-dialog-title>Command Palette</duostrap-dialog-title>
<duostrap-dialog-description>
Search for a command to run.
</duostrap-dialog-description>
<duostrap-command-root>
<duostrap-command-input
id="dialog-command-input"
></duostrap-command-input>
<duostrap-command-content>
<duostrap-command-item>Calendar</duostrap-command-item>
<duostrap-command-item>Search Emoji</duostrap-command-item>
<duostrap-command-item>Calculator</duostrap-command-item>
<duostrap-command-empty>
No results found.
</duostrap-command-empty>
</duostrap-command-content>
</duostrap-command-root>
</duostrap-dialog-content>
</duostrap-dialog-root>Shortcuts & Keywords
Section titled “Shortcuts & Keywords”Display trailing shortcut labels inside menu items and match synonyms via keywords.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<duostrap-command-root id="shortcuts-root">
<duostrap-command-input
id="shortcuts-input"
></duostrap-command-input>
<duostrap-command-content>
<duostrap-command-item>
<span>Profile</span>
<span class="ml-auto font-mono text-xs">⌘P</span>
</duostrap-command-item>
<duostrap-command-item>
<span>Billing</span>
<span class="ml-auto font-mono text-xs">⌘B</span>
</duostrap-command-item>
<duostrap-command-item>
<span>Settings</span>
<span class="ml-auto font-mono text-xs">⌘S</span>
</duostrap-command-item>
<duostrap-command-item>
<span>Keyboard Shortcuts</span>
<span class="ml-auto font-mono text-xs">⌘K</span>
</duostrap-command-item>
<duostrap-command-empty>
No matching shortcuts.
</duostrap-command-empty>
</duostrap-command-content>
</duostrap-command-root>Scrollable
Section titled “Scrollable”Browse a longer list of actions inside the bounded 300px scrolling dropdown container.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="w-full max-w-sm">
<duostrap-command-root id="command-root">
<duostrap-command-input
id="command-input"
></duostrap-command-input>
<duostrap-command-content>
<duostrap-command-item>Calendar</duostrap-command-item>
<duostrap-command-item>Search Emoji</duostrap-command-item>
<duostrap-command-item>Calculator</duostrap-command-item>
<duostrap-command-item>
<span>Profile</span>
<span class="ml-auto font-mono text-xs">⌘P</span>
</duostrap-command-item>
<duostrap-command-item>
<span>Billing</span>
<span class="ml-auto font-mono text-xs">⌘B</span>
</duostrap-command-item>
<duostrap-command-item>
<span>Settings</span>
<span class="ml-auto font-mono text-xs">⌘S</span>
</duostrap-command-item>
<duostrap-command-empty>
No results found.
</duostrap-command-empty>
</duostrap-command-content>
</duostrap-command-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
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.
| 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 | '' |
Other Parts & Events
Section titled “Other Parts & Events”- Input:
placeholder,a11yLabel, andnamedefault to''. - Content:
side="bottom",align="start",sideOffset={4},collisionPadding={8}. - Item:
value,textValue, andkeywordsdefault to'';disableddefaults tofalse. - Empty: No props; shown when no commands match.
- Events:
Rootemitsexecute,valueChange,inputValueChange, andopenChange.