Command
Usage
Include CSS
Import Tailwind and one full A3S UI style bundle.
Or import only the base CSS, Command component CSS, and one style pack.
Using CDN or bundler imports? See the Installation page.
Include JavaScript
Copy or serve the full A3S UI JavaScript bundle.
Or copy or serve the A3S UI runtime and Command script.
Using CDN or bundler imports? See the Installation page.
Add your command HTML
Use <dialog class="command-dialog"> for the command palette variant.
HTML structure
The command menu can be used standalone or inside a native dialog. The structure is:
<dialog class="command-dialog">OptionalDialog variant. Wraps one direct child
<div class="command">. Addaria-labeloraria-labelledbyfor an accessible name.<div class="command">Root command menu. Can also be used standalone without the dialog wrapper. Add
data-filter="manual"when your app owns filtering, such as remote search or a local Lunr index.<header>Search input wrapper. The macro includes a search icon and input.
<input type="text" role="combobox">- Filter input. Use
aria-expanded="true"andaria-controls="{ MENU_ID }"to point to the command list.
<div role="menu" id="{ MENU_ID }">Command list. Set
data-emptyto customize the empty state.<div role="group" aria-labelledby="{ HEADING_ID }">Optional- Groups related command items. Hidden automatically when every item in the group is filtered out.
<span role="heading" id="{ HEADING_ID }">Optional- Group heading. Use an
idwhen the parent group usesaria-labelledby. <div role="menuitem">or<a role="menuitem">- Selectable command item. Use
<a>for navigation and<div>for actions. Supportsdata-filter,data-keywords,data-force,data-keep-command-open,aria-disabled="true", anddata-disabled="true". <span data-shortcut>Optional- Shortcut hint aligned to the inline end of the item.
<span data-indicator>Optional- Item indicator. It becomes visible with
data-checked="true"oraria-selected="true". <hr role="separator">Optional- Separator between groups/items. Hidden while filtering.
JavaScript API
Examples
Basic
A simple command menu in a dialog.
Shortcuts
Groups
Scrollable
RTL
Add dir="rtl" to the command root or an ancestor.