qat

Command palette

CommandPalette. It is copied into your app’s ui/ by qatjs add command: the code is yours to edit.

Example

Ran: nothing

Example.qx28 lines, 2 reactive namesOpen in the playground
import Button from './ui/button/button.qx'
import CommandPalette from './ui/command/command.qx'

export default function Example() {
  let open = state(false)
  let ran = state('')
  return (
    <Button on:click={() => (open = true)}>
      Open the palette
    </Button>
    <p>Ran: {ran || 'nothing'}</p>
    <CommandPalette
      bind:open={open}
      hotkey={false}
      commands={[
        { id: 'orders', label: 'Open orders', group: 'Recent', hint: 'G O', run: () => (ran = 'orders') },
        { id: 'new', label: 'New order', group: 'Recent', hint: 'N', run: () => (ran = 'new') },
        {
          id: 'numbering',
          label: 'Order numbering',
          group: 'Settings',
          keywords: 'invoice prefix',
          run: () => (ran = 'numbering'),
        },
      ]}
    />
  )
}
open stateran state

Add it

shell1 line
npx qatjs add command

CommandPalette

As a custom element: <ui-command-palette>.

CommandPalette: props
PropTypeAttribute
commandsCommand[]property only
filter(query: string) => Command[]property only
openbooleanyes
labelstringyes
placeholderstringyes
emptystringyes
hotkeybooleanyes
CommandPalette: events
EventDetail
on:update:openCustomEvent<boolean>

Keys

KeyDoes
⌘K, Ctrl+Kopen, close
↓ ↑move
Enterrun
Escclose, focus back