Skip to the page
Supply UI

Command palette

In code: CommandPalette

Search for a page or an action and run it from the keyboard. Put it once in the layout.

Preview

Use

The code of the preview above
import { useState } from 'react';
import { Button, CommandPalette, Kbd } from '@/components/ui';
import { Search } from 'lucide-react';

function CommandPaletteDemo() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>
        <Search />
        Search or jump to
        <Kbd>⌘K</Kbd>
      </Button>
      <CommandPalette
        open={open}
        onOpenChange={setOpen}
        placeholder="Type a page or an action"
        items={[
          { id: 'bookings', label: 'Go to bookings', hint: 'Page', href: '#bookings' },
          { id: 'clients', label: 'Go to clients', hint: 'Page', href: '#clients' },
          { id: 'invoice', label: 'New invoice', hint: 'Action' },
          { id: 'export', label: 'Export November as CSV', hint: 'Action' },
        ]}
      />
    </>
  );
}

This page as text, for an AI

Options

OptionTypeWhat it does
items NeededCommandItem[]The pages and actions to search: each an id, a label, and an href to go to or an onSelect to run.
empty ReactNodeShown when nothing matches.
hotkey boolean · default trueOpens with ⌘K (Ctrl K on Windows). On by default.
onOpenChange (open: boolean) => voidCalled with true or false when it opens or closes.
open booleanWhether it is open, when your state holds it; use with onOpenChange.
placeholder stringA hint shown while it is empty. Not a label: give it a label as well.

Without React

The same look on any HTML, with the classes (React only).

With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:

components/button.csscomponents/card.csscomponents/table.csscomponents/tabs.csscomponents/popups.csscomponents/dialog.csscomponents/icons.csscomponents/input-group.csscomponents/calendar.csscomponents/button-group-toggle.csscomponents/code-input.csscomponents/tab-bar.csscomponents/command-palette.csscomponents/prose.csscomponents/carousel-arrows.csscomponents/page-transitions.cssparts/carousel.cssparts/calendar.cssparts/date-time-typed-part.cssparts/listbox.cssparts/date-picker.cssparts/board.css

In the examples

Small screens made with it and the rest of the kit. They work: click, type and choose in them.

Lately
Invoice 0412Kestrel StudioNovember
Jump anywhere with ⌘K Pages and actions in one search

Showing things: states, do and don’t

Search for a page or an action and run it from the keyboard (⌘K). Once, in the layout.

States. Lists, tables and boards have three more states besides their content: empty (Empty, with the first action inside), loading (Skeleton) and failed (Alert tone="danger"). A chosen row shows in ink, never in the brand colour.

Do

  • Put numbers, dates and codes in ui-mono (in a table cell, ui-num, which also aligns them).
  • Let a Table turn into blocks on a phone; give it scroll only when it is read down its columns.
  • Show a status in words and colour together (Badge tone="success" with "Paid"), never colour alone.

Don't

  • Don't put a card round a Table, List, Cells, Calendar or Empty: they draw their own box.
  • Don't truncate a name or a price to fit; let it wrap. Truncate only file names and addresses.
  • Don't use the status colours (success, warning, danger, info) for anything but those meanings.