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.
Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add commandAlso works with shadcn:
npx shadcn@latest add @ritla/commandDependencies it brings
@base-ui/react@phosphor-icons/reactOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
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
| Prop | Type | Default | Description |
|---|---|---|---|
groups | { heading?: string; items: CommandItemData[] }[] | None | The sections and their rows. |
size | "sm" | "md" | "sm" | Figma's Size for the rows. |
stacked | boolean | false | Figma's Text = Stacked: supporting text under the label. |
label / placeholder | string | "Search commands" / "Search" | The search field's name and placeholder, in the page language by default. |
empty | ReactNode | None | Shown when nothing matches. |
footer / footerAction | boolean / ReactNode | true | The key hints, and a control at their end. |
onSelect | (item) => void | None | Runs after the row's own onSelect. |
CommandItemData
| Prop | Type | Default | Description |
|---|---|---|---|
value / label | string | None | The row's id and text. |
supportingText | string | None | Figma's Supporting text; searched too. |
icon / avatar / dot | IconComponent / ReactNode / "green" | "amber" | "red" | "brand" | "gray" | None | Figma's Type: an icon, an avatar or a status dot. |
shortcut | string[] | None | The command's app shortcut, display only. |
keywords | string[] | None | Other words that find the row, such as English names. |
onSelect / disabled | () => void / boolean | None | What picking it does. |
CommandDialog
| Prop | Type | Default | Description |
|---|---|---|---|
trigger / triggerLabel | ReactElement / ReactNode | None | The button that opens it, and its label. |
shortcut | boolean | true | ⌘K on Mac, Ctrl+K elsewhere, on the physical K key in any keyboard layout. |
open / defaultOpen / onOpenChange | boolean | None | Controls whether it's open. |
title | string | "Command menu" | The dialog's name for screen readers. |
… | CommandProps | None | Every 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.
| Key | Action |
|---|---|
| ⌘KCtrl+K | Opens and closes it from anywhere. |
| ArrowDownArrowUp | Through the rows, while focus stays in the search field. |
| Enter | Runs the highlighted row and closes the dialog. |
| Esc | Closes the dialog and returns focus. |
ARIA
- The search field is a
comboboxcontrolling alistbox; the highlighted row is announced througharia-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-16atmd), the fieldbody-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 “ن”).
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- Untranslated attribute text (placeholder, alt, title, aria-label, button value)
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)