Components Menus and overlays

Command

A searchable list of commands or choices: type to filter, arrows and Enter to pick.

import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut } from '@kition/tessera-ui'

When to use

  • A command palette, a searchable picker inside a popover.

Examples

A command palette
command.tsx
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, toast } from '@kition/tessera-ui'
import { FileTextIcon, SettingsIcon, TableIcon } from '@kition/tessera-icons/react'

export default function Demo() {
  const run = (name: string) => toast('info', name)
  return (
    <div style={{ width: 'min(100%, 420px)', border: '1px solid var(--kit-border)', borderRadius: 12, background: 'var(--kit-surface)' }}>
      <Command>
        <CommandInput placeholder="Type a command…" />
        <CommandList>
          <CommandEmpty>No matching command.</CommandEmpty>
          <CommandGroup heading="Create">
            <CommandItem onSelect={() => run('New document')}>
              <FileTextIcon size={16} /> New document <CommandShortcut>⌘N</CommandShortcut>
            </CommandItem>
            <CommandItem onSelect={() => run('New table')}>
              <TableIcon size={16} /> New table
            </CommandItem>
          </CommandGroup>
          <CommandSeparator />
          <CommandGroup heading="App">
            <CommandItem onSelect={() => run('Settings')}>
              <SettingsIcon size={16} /> Settings <CommandShortcut>⌘,</CommandShortcut>
            </CommandItem>
          </CommandGroup>
        </CommandList>
      </Command>
    </div>
  )
}

Props

Command

A searchable list of commands or choices (cmdk): type to filter, arrows and Enter to pick.

No props.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

CommandInput

PropTypeDefaultDescription
wrapClassNamestring—

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

CommandList

No props.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

CommandEmpty

No props.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

CommandGroup

No props.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

CommandItem

No props.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

CommandSeparator

No props.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

CommandShortcut

A shortcut at the end of a command item.

No props.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

Used in

7 of Kition's 16 kits use these components.

  • Doc
  • Effect
  • Film
  • Photo
  • Sheet
  • Slide
  • Table