Skip to content

Command

Get Ritla UI

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

Open in Figma

Preview

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

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add command

    Also works with shadcn: npx shadcn@latest add @ritla/command

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or 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

command.tsx
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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

API reference

Command

PropTypeDefaultDescription
groups{ heading?: string; items: CommandItemData[] }[]NoneThe 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.
emptyReactNodeNoneShown when nothing matches.
footer / footerActionboolean / ReactNodetrueThe key hints, and a control at their end.
onSelect(item) => voidNoneRuns after the row's own onSelect.

CommandItemData

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

CommandDialog

PropTypeDefaultDescription
trigger / triggerLabelReactElement / ReactNodeNoneThe 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 / onOpenChangebooleanNoneControls whether it's open.
titlestring"Command menu"The dialog's name for screen readers.
…CommandPropsNoneEvery 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 “ن”).

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R012Untranslated attribute text (placeholder, alt, title, aria-label, button value)
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space
  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)