Dialog Command Palette
The same list summoned over the page.
<Dialog>
<Dialog.Trigger asChild>
<Button variant="soft">Open Command Palette</Button>
</Dialog.Trigger>
<Dialog.Content width="sm">
<Command>Filters a list of actions as the user types.
import { Command } from "@/fragments/ui";Source<div style={{ maxWidth: '400px', width: '100%' }}>
<Command>
<Command.Input placeholder="Type a command..." />
<Command.List>
<Command.Item onItemSelect={() => {}}>Open File</Command.Item>
<Command.Item onItemSelect={() => {}}>Save Document</Command.Item>npx @usefragments/cli add commandWrites src/fragments/ui/components/Command plus what it imports, the globals stylesheet, and .fragments/registry-lock.json, then prints the packages to add. No account, no key.
Your own registry: publish from Fragments Cloud and add --registry org/name. Connect a workspace.
Command is a compound: import the root and reach its parts through dot notation.
Command.InputCommand.ListCommand.ItemCommand.GroupCommand.EmptyCommand.SeparatorSearch field over a flat list.
<div style={{ maxWidth: '400px', width: '100%' }}>
<Command>
<Command.Input placeholder="Type a command..." />
<Command.List>
<Command.Item onItemSelect={() => {}}>Open File</Command.Item>
<Command.Item onItemSelect={() => {}}>Save Document</Command.Item>
<Command.Item onItemSelect={() => {}}>Print</Command.Item>
<Command.Empty>No results found.</Command.Empty>
</Command.List>
</Command>
</div>The same list summoned over the page.
<Dialog>
<Dialog.Trigger asChild>
<Button variant="soft">Open Command Palette</Button>
</Dialog.Trigger>
<Dialog.Content width="sm">
<Command>Category labels survive filtering.
<div style={{ maxWidth: '400px', width: '100%' }}>
<Command>
<Command.Input placeholder="Search..." />
<Command.List>
<Command.Group heading="Suggestions">
<Command.Item onItemSelect={() => {}}>Calendar</Command.Item>Leading glyphs speed up scanning.
<div style={{ maxWidth: '400px', width: '100%' }}>
<Command>
<Command.Input placeholder="What do you need?" />
<Command.List>
<Command.Item onItemSelect={() => {}}>
<span style={{ marginRight: '0.5rem', fontSize: '1rem' }}>+</span> New DocumentProp | Type | Default | Description |
|---|---|---|---|
childrenRequired | node | Not set | Command.Input, Command.List, and other sub-components |
search | string | Not set | Controlled search value |
defaultSearch | string | | Default search value (uncontrolled) |
onSearchChange | function | Not set | Called when search input changes |
filter | function | Not set | Custom filter function. Return 0 to hide, >0 to show. |
loop | boolean | true | Whether to loop keyboard navigation |
hosted | boolean | false | The Command sits inside another surface (a Popover, a Dialog) that draws the frame, so it draws none of its own |