Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Command

Command menu for search and quick actions.

Installation

pnpm add @heyramzi/ui bits-ui

Usage

import * as Command from "@heyramzi/ui/shadcn/command";
<Command.Root>
  <Command.Input placeholder="Type a command or search..." />
  <Command.List>
    <Command.Empty>No results found.</Command.Empty>
    <Command.Group heading="Suggestions">
      <Command.Item>Calendar</Command.Item>
      <Command.Item>Search emoji</Command.Item>
    </Command.Group>
    <Command.Separator />
    <Command.Group heading="Settings">
      <Command.Item>
        Profile
        <Command.Shortcut>⌘P</Command.Shortcut>
      </Command.Item>
    </Command.Group>
  </Command.List>
</Command.Root>

Keyboard and accessibility

Key Does
Arrow Down Ctrl N Ctrl J Moves to the next item.
Arrow Up Ctrl P Ctrl K Moves to the previous item.
Home Moves to the first item.
End Moves to the last item.
Enter Runs the highlighted item.
  • Focus stays in the search box while the arrow keys move a highlight through the list.
  • Typing filters the list. Command.Empty shows when nothing matches.
  • The highlight stops at the ends unless loop is set.
  • Command.Dialog adds a hidden title, and works like a dialog: Esc closes it.

API reference

Command.Root

api bindable CommandRootApi | null
Default null
ref bindable HTMLElement | null
Default null
value bindable string
Default ""
class string
...rest
Every prop of Command.Root from bits-ui
Prop Type Default
api bindable CommandRootApi | null null
ref bindable HTMLElement | null null
value bindable string ""
class string
...rest Every prop of Command.Root from bits-ui

Command.Input

wrapperClass string
Classes for the row that holds the glyph, the field and `trailing`.
size "default" | "lg"
Default "default"
`lg` is the standalone search header; `default` is a combobox popover.
trailing Snippet
Right-aligned affordances: a dismiss hint, a close button, a scope chip.
ref bindable HTMLElement | null
Default null
class string
value bindable string
Default ""
...rest
Every prop of Command.Input from bits-ui except size
Prop Type Default
wrapperClass

Classes for the row that holds the glyph, the field and `trailing`.

string
size

`lg` is the standalone search header; `default` is a combobox popover.

"default" | "lg" "default"
trailing

Right-aligned affordances: a dismiss hint, a close button, a scope chip.

Snippet
ref bindable HTMLElement | null null
class string
value bindable string ""
...rest Every prop of Command.Input from bits-ui except size

Command.List

ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of Command.List from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
children Snippet
...rest Every prop of Command.List from bits-ui

Command.Empty

ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of Command.Empty from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
...rest Every prop of Command.Empty from bits-ui

Command.Group

heading string
ref bindable HTMLElement | null
Default null
class string
children Snippet
value Command.Group
...rest
Every prop of Command.Group from bits-ui
Prop Type Default
heading string
ref bindable HTMLElement | null null
class string
children Snippet
value Command.Group
...rest Every prop of Command.Group from bits-ui

Command.Item

ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of Command.Item from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
children Snippet
...rest Every prop of Command.Item from bits-ui

Command.Separator

ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of Command.Separator from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
...rest Every prop of Command.Separator from bits-ui

Command.Shortcut

ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLElement> from svelte/elements
Prop Type Default
ref bindable HTMLElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLElement> from svelte/elements

Command.Dialog

portalProps DialogPrimitive.PortalProps
children required Snippet
title string
Default "Command Palette"
description string
Default "Search for a command to run..."
showCloseButton boolean
Default false
closeLabel string
Default "Close"
What a screen reader calls the close button, in the app's language.
class string
open bindable boolean
Default false
ref bindable HTMLElement | null
Default null
value bindable string
Default ""
...rest
Every prop of Dialog.Root from bits-ui except child, children
...rest
Every prop of Command.Root from bits-ui except child, children
Prop Type Default
portalProps DialogPrimitive.PortalProps
children required Snippet
title string "Command Palette"
description string "Search for a command to run..."
showCloseButton boolean false
closeLabel

What a screen reader calls the close button, in the app's language.

string "Close"
class string
open bindable boolean false
ref bindable HTMLElement | null null
value bindable string ""
...rest Every prop of Dialog.Root from bits-ui except child, children
...rest Every prop of Command.Root from bits-ui except child, children

Command.LinkItem

ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of Command.LinkItem from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
...rest Every prop of Command.LinkItem from bits-ui

Command.Loading

ref bindable HTMLElement | null
Default null
...rest
Every prop of Command.Loading from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
...rest Every prop of Command.Loading from bits-ui