Skip to content

Command

Searchable command palette with groups, shortcuts and keyboard navigation.

Installation

bun add @xerobi/ui
import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from "@xerobi/ui/command"

This component is client-side. In Astro, hydrate it with a client directive.

Examples

Default

import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@xerobi/ui/command"

export function CommandDefault() {
  return (
    <Command className="w-80 rounded-lg border">
      <CommandInput placeholder="Type a command" />
      <CommandList>
        <CommandEmpty>No results.</CommandEmpty>
        <CommandGroup heading="Suggestions">
          <CommandItem>Calendar</CommandItem>
          <CommandItem>Search</CommandItem>
          <CommandItem>Settings</CommandItem>
        </CommandGroup>
      </CommandList>
    </Command>
  )
}

API reference

Command

No props of its own.

CommandDialog

PropTypeDescription
titlestring
descriptionstring
classNamestring
showCloseButtonboolean
children*string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode>

CommandEmpty

No props of its own.

CommandGroup

No props of its own.

CommandInput

No props of its own.

CommandItem

No props of its own.

CommandList

No props of its own.

CommandSeparator

No props of its own.

CommandShortcut

Also accepts every prop of <span> element.

No props of its own.

Styling hooks: [data-slot="command"], [data-slot="command-input-wrapper"], [data-slot="command-input"], [data-slot="command-list"], [data-slot="command-empty"], [data-slot="command-group"], [data-slot="command-separator"], [data-slot="command-item"], [data-slot="command-shortcut"].

Search documentation

Search pages, components and blocks.