Overview Button Copy button Field Input Number field Textarea Select Combobox Multiselect Date picker Date range picker Date-time picker Checkbox Radio group Position picker Switch Slider Dropzone Device controls Avatar Badge Card Collapsible Kbd Map Matrix Proportion bar Separator Stat Table Timeline Chat Playback Pagination Charts Chart theming Profile chart Time series chart Bar chart Isopleth chart TS diagram Box plot Rose chart Calendar chart Banner Toast Loader Progress Skeleton Empty state Error state Dropdown menu Tooltip Info tooltip Dialog Sheet Resizable Confirm dialog Breadcrumbs Command palette Mobile menu Navigation list Outline Scroll rail Sidebar Tabs
Command palette
Search and run from the keyboard: every page and action in one list, opened with ⌘K.
Palette
Type and the list narrows and re-sorts, best match first, with the match set in ink. Try “mis”, “csv”, or “vestland”.
This page's own. CtrlK opens the site's.
<script lang="ts">
let open = $state(false);
const items: CommandItem[] = [
{ id: 'missions', label: 'Missions', icon: 'route', group: 'Go to', href: '/missions' },
{
id: 'new-mission',
label: 'Plan a mission',
description: 'A day on the water for one vessel',
icon: 'plus',
group: 'Actions',
shortcut: ['N'],
onselect: planMission,
},
];
</script>
<Sidebar {state}>
<SidebarSearch onclick={() => (open = true)} />
...
</Sidebar>
<CommandPalette
bind:open
{items}
groups={[{ label: 'Icons', grid: true, searchOnly: true }]}
placeholder="Search pages and actions"
/> In the sidebar
SidebarSearch is the way in: a row that looks like a field, set into the ground where the current page is raised. Collapse the sidebar and it's the magnifying glass.
Categories
With more than one group, each is also a category: chips under the field, All first. While searching, each chip counts its matches, and the empty ones fade.
- Picking one keeps the query, so “buoy” in All becomes “buoy” in Icons with one press of Tab.
griddraws a chosen category as tiles, the icon large with its name under it; the arrows then move in all four directions. In All it's still a row, the icon at the front.searchOnlyleaves a group out of the list until it's searched or chosen. Its chip is always there.
Keys
CtrlK Open it, from anywhere. Again to close.
↑↓ Move through the list. It wraps at either end.
Enter Open the lit row, or run it.
CtrlEnter Open a page in a new tab, and stay where you are.
ShiftEnter The row’s second action, when it has one: Copy SVG on an icon.
Tab Step through the categories. Shift goes back.
Esc Close, and go back to where you were.
Rules
- One palette per app, on ⌘K, holding everything: pages, records, and the actions that work from anywhere.
- Name an action by what it does, starting with the verb: "Plan a mission", "Invite a member". A page is just its name.
- The description is a few words, for telling two rows apart. Skip it when the label says it all.
- Add keywords for the other words people try: "download" for Export, "theme" for dark mode.
- An action whose effect depends on the state says the state it will lead to: "Switch to dark mode", not "Toggle theme".
- Group by kind, most used first. The groups are the categories too, so name them as nouns: Pages, Projects, Icons.
- A group told apart by looking (icons, colours) is a grid. A long one is searchOnly, so it doesn’t bury the rest.
- Give an item a verb when Enter neither opens nor runs: "Copy name".
- One more action at most, as alt, on Shift Enter. More than two and it wants its own page.
- Nothing destructive runs straight from Enter. Delete opens its confirmation.
- Give it a visible way in, the search row in the sidebar. The shortcut is for those who already know it.