Build · New

Command

Search and run any command from anywhere, keyboard first. ⌘K or Ctrl+K opens it, and it understands the Arabic letter forms people type in different ways.

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

Installation

SoonInstalling from the registry opens at launch. Until then the command below is what it will be.
npx shadcn@latest add @ritla/command

Dependencies it brings: @base-ui/react, @phosphor-icons/react

Usage

import { CommandDialog } from "@/components/ui/command";
<CommandDialog
  trigger={<Button variant="outline" />}
  triggerLabel="Search commands"
  groups={[
    { heading: "Suggestions", items: [{ value: "transfer", label: "New transfer", icon: ArrowsLeftRightIcon, onSelect: newTransfer }] },
  ]}
/>

Examples

People, stacked

Command inline on the page, without a dialog: avatars and the handle under the name (stacked), which is searched too.

Status dots

dot for each row's status, with the status in words beside it so color is never the only signal. Size md; the off row is disabled.

Search that reads Arabic

Type “اضافه” to find “إضافة بطاقة”, or “فاتوره” for “دفع الفاتورة”: the search folds hamza forms, taa marbuta and alef maqsura, ignores diacritics and tatweel, and matches Arabic-Indic digits. keywords add English names: “invoice”. Type something that isn't there to see the empty state.

API reference

Command

PropTypeDefaultDescription
groups{ heading?: string; items: CommandItemData[] }[]The sections and their rows.
size"sm" | "md""sm"Figma's Size for the rows.
stackedbooleanfalseFigma's Text = Stacked: supporting text under the label.
label / placeholderstring"Search commands" / "Search"The search field's name and placeholder, in the page language by default.
emptyReactNodeShown when nothing matches.
footer / footerActionboolean / ReactNodetrueThe key hints, and a control at their end.
onSelect(item) => voidRuns after the row's own onSelect.

CommandItemData

PropTypeDefaultDescription
value / labelstringThe row's id and text.
supportingTextstringFigma's Supporting text; searched too.
icon / avatar / dotIconComponent / ReactNode / "green" | "amber" | "red" | "brand" | "gray"Figma's Type: an icon, an avatar or a status dot.
shortcutstring[]The command's app shortcut, display only.
keywordsstring[]Other words that find the row, such as English names.
onSelect / disabled() => void / booleanWhat picking it does.

CommandDialog

PropTypeDefaultDescription
trigger / triggerLabelReactElement / ReactNodeThe button that opens it, and its label.
shortcutbooleantrue⌘K on Mac, Ctrl+K elsewhere, on the physical K key in any keyboard layout.
open / defaultOpen / onOpenChangebooleanControls whether it's open.
titlestring"Command menu"The dialog's name for screen readers.
…CommandPropsEvery Command prop.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
⌘KCtrl+KOpens and closes it from anywhere.
ArrowDownArrowUpThrough the rows, while focus stays in the search field.
EnterRuns the highlighted row and closes the dialog.
EscCloses the dialog and returns focus.

ARIA

  • The search field is a combobox controlling a listbox; the highlighted row is announced through aria-activedescendant.
  • Sections are labelled groups, and the dialog has a name (Command menu).
  • Status dots come with a word; the key hints repeat what screen readers already announce, so they're hidden from them.

Arabic and RTL notes

Mirrors

  • Icons and avatars sit on the right, shortcuts on the left, and section headings start on the right.
  • Type in either language and the field follows it (dir="auto").

Does not mirror

  • Shortcut keys (⌘ T) stay left to right, as on the keyboard, and the Return key's glyph doesn't mirror.
  • The up and down arrows.
Numerals
Arabic-Indic digits in the search match Western ones: “٣” finds “3”.
Arabic typography
Rows body-14 (body-16 at md), the field body-16; rows grow with Arabic line heights.
Mixed-direction text
⌘K works on the same K key even with an Arabic keyboard layout (where it types “ن”).

All components ›