Command menu for search and quick actions.
About
The Command component is a port of cmdk by Dip: the same fuzzy filtering, ranking and keyboard navigation, with no JavaScript dependency.
Installation
Usage
<Command Class="max-w-sm rounded-lg border">
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup Heading="Suggestions">
<CommandItem>Calendar</CommandItem>
<CommandItem>Search Emoji</CommandItem>
<CommandItem>Calculator</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup Heading="Settings">
<CommandItem>Profile</CommandItem>
<CommandItem>Billing</CommandItem>
<CommandItem>Settings</CommandItem>
</CommandGroup>
</CommandList>
</Command>To open the menu with ⌘K (Ctrl+K on Windows and Linux), put it in a CommandDialog and toggle it with a KeyboardShortcut. OnSelect passes the selected item's value: close the dialog, then run the command it names.
<KeyboardShortcut Key="k" OnPressed="() => _open = !_open" />
<CommandDialog @bind-Open="_open">
<Command>
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup Heading="Suggestions">
<CommandItem OnSelect="RunCommand">Calendar</CommandItem>
<CommandItem OnSelect="RunCommand">Search Emoji</CommandItem>
<CommandItem OnSelect="RunCommand">Calculator</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</CommandDialog>
@code {
private bool _open;
private void RunCommand(string value)
{
_open = false;
}
}Composition
Use the following composition to build a Command:
Command
├── CommandInput
└── CommandList
├── CommandEmpty
├── CommandGroup
│ ├── CommandItem
│ └── CommandItem
├── CommandSeparator
└── CommandGroup
├── CommandItem
└── CommandItemBasic
A simple command menu in a dialog.
Command Palette
Search for a command to run...
Shortcuts
Command Palette
Search for a command to run...
Groups
A command menu with groups, icons and separators.
Command Palette
Search for a command to run...
Scrollable
Scrollable command menu with multiple items.
Command Palette
Search for a command to run...
RTL
To enable RTL support in Blazix, see the RTL configuration guide.
Translated with AI for the demo, so it may have mistakes.
API Reference
Command
Other attributes are passed to the element it renders.
CommandDialog
Other attributes are passed to the element it renders.
CommandEmpty
Other attributes are passed to the element it renders.
CommandGroup
Other attributes are passed to the element it renders.
CommandInput
Other attributes are passed to the element it renders.
CommandItem
Other attributes are passed to the element it renders.
CommandList
Other attributes are passed to the element it renders.
CommandSeparator
Other attributes are passed to the element it renders.
CommandShortcut
Other attributes are passed to the element it renders.