XiodUI
HomeDocs
OverviewComponentsStyling & CustomizationChangelog

Components

  • Accordion
  • Agent Steps
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Autocomplete
  • Avatar
  • Badge
  • Breadcrumb
  • Button
  • Button Group
  • Button Split
  • Calendar
  • Card
  • Carousel
  • Checkbox
  • Circular Progress
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy To Clipboard
  • Corner Badge
  • Dashboard Grid
  • Date Picker
  • Dialog
  • Dot Matrix
  • Draggable
    Updated
  • Drawer
  • Empty
  • Field
  • Fieldset
  • File Upload
    Updated
  • Form
  • Frame
  • Gauge
  • Grid
  • Group
  • Input
  • Input Group
  • Input OTP
  • Input Payment
  • Input Phone
    Updated
  • Input Sensitive
  • Kbd
  • Kinetic Click
  • Label
  • List Box
    Updated
  • Loader
  • Marker
  • Menu
  • Menubar
  • Message
  • Meter
  • Morphic Toast
  • Navigation Menu
  • Number Field
  • Option Picker
  • Orb
  • Pagination
  • Popover
  • Preview Card
    Updated
  • Progress
  • Radio
  • Resizable
  • Ruler Picker
  • Scroll Area
  • Scroll Bar
  • Select
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Sortable
  • Switch
  • Table
  • Tabs
  • Text
  • Textarea
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Toolbar
  • Tooltip
  • Waveform
  • Wheel Picker

Loading...

Preview Skeleton

Installation Skeleton

Usage Skeleton

API Reference Skeleton

Sponsors

Support the development of XiodUI and help us build the best component library on Earth.

+++
Sponsor on GitHub

Command

Previous: ComboboxNext: Context Menu

A searchable list of commands, usually opened as a palette with a keyboard shortcut.

Preview

Loading Preview...

Installation

bun add xiod-ui

Usage

Imports

1import {2  Command,3  CommandCollection,4  CommandDialog,5  CommandDialogPopup,6  CommandDialogTrigger,7  CommandEmpty,8  CommandFooter,9  CommandGroup,10  CommandGroupLabel,11  CommandInput,12  CommandItem,13  CommandList,14  CommandPanel,15  CommandSeparator,16  CommandShortcut,17  CommandCreateHandle18} from "xiod-ui/command";

Anatomy

1<CommandDialog>2  <CommandDialogTrigger />3  <CommandDialogPopup>4    <Command>5      <CommandInput />6      <CommandPanel>7        <CommandEmpty />8        <CommandList>9          <CommandGroup>10            <CommandGroupLabel />11            <CommandCollection>12              <CommandItem>13                <CommandShortcut />14              </CommandItem>15            </CommandCollection>16          </CommandGroup>17          <CommandSeparator />18        </CommandList>19      </CommandPanel>20      <CommandFooter />21    </Command>22  </CommandDialogPopup>23</CommandDialog>

API Reference

Detailed documentation of properties and options.

Command

PropTypeDefaultDescription
actionsRef
RefObject<AutocompleteRootActions | null>
–

A ref to imperative actions.

  • unmount: Ends the closing phase of the autocomplete after an externally controlled closing animation finishes.

Call preventUnmountOnClose() in onOpenChange first, otherwise the autocomplete completes closing on its own. Whether it leaves the DOM is decided by keepMounted on the portal.

ComboboxContext Menu
  • close: Closes the autocomplete imperatively when called.
  • autoHighlight
    boolean|"always"
    false

    Whether the first matching item is highlighted automatically.

    • true: highlight after the user types and keep the highlight while the query changes.
    • 'always': always highlight the first item.
    children
    ReactNode
    –

    The content of the component.

    defaultOpen
    boolean
    false

    Whether the popup is initially open.

    To render a controlled popup, use the open prop instead.

    defaultValue
    string | number | readonly string[]
    –

    The uncontrolled input value of the autocomplete when it's initially rendered.

    To render a controlled autocomplete, use the value prop instead.

    disabled
    boolean
    false

    Whether the component should ignore user interaction.

    filter
    AriaCombobox.Props<ItemValue, 'none'>['filter']
    –

    Filter function used to match items against the input query.

    filteredItems
    readonly unknown[] | readonly Group<unknown>[]
    –

    Filtered items to display in the list. When provided, the list uses these items instead of filtering the items prop internally. When items is also provided, this array must preserve its flat or grouped structure. Nullish entries are not supported, as in items. Use when you want to control filtering logic externally with the useFilter() hook.

    form
    string
    –

    Identifies the form that owns the internal input. Useful when the autocomplete is rendered outside the form.

    grid
    boolean
    false

    Whether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.

    highlightItemOnHover
    boolean
    true

    Whether moving the pointer over items should highlight them. Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state.

    id
    string
    –

    The id of the component.

    inline
    boolean
    false

    Whether the list is rendered inline without using the component's own popup.

    Specify open unconditionally in conjunction with this prop so the list is considered visible: <Autocomplete.Root inline open>

    inputRef
    Ref<HTMLInputElement>
    –

    A ref to the hidden input element.

    items
    readonly unknown[]
    –

    The items to be displayed in the list. Can be either a flat array of items or an array of groups with items. Nullish entries are not supported: remove them from the data before passing it.

    itemToStringValue
    ((itemValue: unknown) => string)
    –

    When the item values are objects (<Autocomplete.Item value={object}>), this function converts the object value to a string representation for both display in the input and form submission. If the shape of the object is { value, label }, the label will be used automatically without needing to specify this prop.

    keepHighlight
    boolean
    false

    Whether the highlighted item should be preserved when the pointer leaves the list.

    limit
    number
    -1

    The maximum number of items to display in the list.

    locale
    LocalesArgument
    –

    The locale to use for string comparison. Defaults to the user's runtime locale.

    loopFocus
    boolean
    true

    Whether to loop keyboard focus back to the input when the end of the list is reached while using the arrow keys. The first item can then be reached by pressing <kbd>ArrowDown</kbd> again from the input, or the last item can be reached by pressing <kbd>ArrowUp</kbd> from the input. The input is always included in the focus loop per [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/). When disabled, focus does not move when on the last element and the user presses <kbd>ArrowDown</kbd>, or when on the first element and the user presses <kbd>ArrowUp</kbd>.

    modal
    boolean
    false

    Determines if the popup enters a modal state when open.

    • true: user interaction is limited to the popup: document page scroll is locked and pointer interactions on outside elements are disabled.
    • false: user interaction with the rest of the document is allowed.

    On touch devices, a true modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior.

    mode
    "none"|"inline"|"list"|"both"
    'list'

    Controls how the autocomplete behaves with respect to list filtering and inline autocompletion.

    • list (default): items are dynamically filtered based on the input value. The input value does not change based on the active item.
    • both: items are dynamically filtered based on the input value, which will temporarily change based on the active item (inline autocompletion).
    • inline: items are static (not filtered), and the input value will temporarily change based on the active item (inline autocompletion).
    • none: items are static (not filtered), and the input value will not change based on the active item.
    name
    string
    –

    Identifies the field when a form is submitted.

    onItemHighlighted
    ((highlightedValue: unknown, eventDetails: HighlightEventDetails) => void)
    –

    Callback fired when an item is highlighted or unhighlighted. Receives the highlighted item value (or undefined if no item is highlighted) and event details with a reason property describing why the highlight changed. The reason can be:

    • 'keyboard': the highlight changed due to keyboard navigation.
    • 'pointer': the highlight changed due to pointer hovering. The event may be a MouseEvent rather than a PointerEvent.
    • 'none': the highlight changed for another reason, such as typing, autoHighlight, the item list changing, or the popup opening or closing.
    onOpenChange
    ((open: boolean, eventDetails: AutocompleteRootOpenChangeEventDetails) => void)
    –

    Event handler called when the popup is opened or closed.

    onOpenChangeComplete
    ((open: boolean) => void)
    –

    Event handler called after any animations complete when the popup is opened or closed.

    onValueChange
    ((value: string, eventDetails: AutocompleteRootChangeEventDetails) => void)
    –

    Event handler called when the input value of the autocomplete changes.

    open
    boolean
    –

    Whether the popup is currently open. Use when controlled.

    openOnInputClick
    boolean
    false

    Whether the popup opens when clicking the input.

    readOnly
    boolean
    false

    Whether the user should be unable to choose a different option from the popup.

    required
    boolean
    false

    Whether the user must choose a value before submitting a form.

    submitOnItemClick
    boolean
    false

    Whether clicking an item should submit the autocomplete's owning form. By default, clicking an item via a pointer or <kbd>Enter</kbd> key does not submit the owning form. Useful when the autocomplete is used as a single-field form search input.

    value
    string | number | readonly string[]
    –

    The input value of the autocomplete. Use when controlled.

    virtualized
    boolean
    false

    Whether the items are being externally virtualized.

    CommandCollection

    PropTypeDefaultDescription
    childrenReq
    (item: any, index: number) => ReactNode
    –

    The content of the component.

    CommandDialog

    PropTypeDefaultDescription
    actionsRef
    RefObject<DialogRootActions | null>
    –

    A ref to imperative actions.

    • unmount: Ends the closing phase of the dialog after an externally controlled closing animation finishes.

    Call preventUnmountOnClose() in onOpenChange first, otherwise the dialog completes closing on its own. Whether it leaves the DOM is decided by keepMounted on the portal.

    • close: Closes the dialog imperatively when called.
    children
    ReactNode | PayloadChildRenderFunction<Payload>
    –

    The content of the dialog. This can be a regular React node or a render function that receives the payload of the active trigger.

    defaultOpen
    boolean
    false

    Whether the dialog is initially open.

    To render a controlled dialog, use the open prop instead.

    defaultTriggerId
    string|null
    –

    ID of the trigger that the dialog is associated with. This is useful in conjunction with the defaultOpen prop to create an initially open dialog.

    disablePointerDismissal
    boolean
    false

    Whether to prevent the dialog from closing on outside presses. For non-modal dialogs, this also prevents the dialog from closing when focus moves outside of it.

    handle
    DialogHandle<Payload>
    –

    A handle to associate the dialog with a trigger. If specified, allows external triggers to control the dialog's open state. Can be created with the Dialog.createHandle() method.

    modal
    boolean|"trap-focus"
    true

    Determines if the dialog enters a modal state when open.

    • true: user interaction is limited to just the dialog: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled.
    • false: user interaction with the rest of the document is allowed.
    • 'trap-focus': focus is trapped inside the dialog, but document page scroll is not locked and pointer interactions outside of it remain enabled.

    When modal is true or 'trap-focus', render <Dialog.Close> inside <Dialog.Popup> so touch screen readers can escape the popup.

    onOpenChange
    ((open: boolean, eventDetails: DialogRootChangeEventDetails) => void)
    –

    Event handler called when the dialog is opened or closed.

    onOpenChangeComplete
    ((open: boolean) => void)
    –

    Event handler called after any animations complete when the dialog is opened or closed.

    open
    boolean
    –

    Whether the dialog is currently open.

    triggerId
    string|null
    –

    ID of the trigger that the dialog is associated with. This is useful in conjunction with the open prop to create a controlled dialog. There's no need to specify this prop when the dialog is uncontrolled (that is, when the open prop is not set).

    CommandDialogPopup

    Accepts className, style and render, plus every native attribute of the element it renders.

    PropTypeDefaultDescription
    finalFocus
    boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)
    –

    Determines the element to focus when the dialog is closed.

    • false: Do not move focus.
    • true: Move focus based on the default behavior (trigger or previously focused element).
    • RefObject: Move focus to the ref element.
    • function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.
    initialFocus
    boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null)
    –

    Determines the element to focus when the dialog is opened. By default, focus moves to the first tabbable element inside the popup, except when the dialog is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard.

    • false: Do not move focus.
    • true: Move focus based on the default behavior (first tabbable element or popup).
    • RefObject: Move focus to the ref element.
    • function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false

    CommandDialogTrigger

    Accepts className, style and render, plus every native attribute of the element it renders.

    PropTypeDefaultDescription
    handle
    DialogHandle<unknown>
    –

    A handle to associate the trigger with a dialog. Can be created with the Dialog.createHandle() method.

    id
    string
    –

    ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for the dialog in controlled mode (with the DialogRoot triggerId prop).

    nativeButton
    boolean
    true

    Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

    payload
    unknown
    –

    A payload to pass to the dialog when it is opened.

    CommandEmpty

    Accepts className, style and render, plus every native attribute of the element it renders.

    CommandFooter

    Accepts render, plus every native <div> attribute.

    CommandGroup

    Accepts className, style and render, plus every native attribute of the element it renders.

    PropTypeDefaultDescription
    items
    readonly any[]
    –

    Items to be rendered within this group. When provided, child Collection components will use these items.

    CommandGroupLabel

    Accepts className, style and render, plus every native attribute of the element it renders.

    CommandInput

    Accepts className, style and render, plus every native attribute of the element it renders.

    PropTypeDefaultDescription
    clearIcon
    ReactNode
    –

    Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

    clearProps
    ComboboxClearProps
    –

    Props for the clear button, such as aria-label or className.

    disabled
    boolean
    false

    Whether the component should ignore user interaction.

    icon
    ReactNode
    –

    Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

    showClear
    boolean
    –

    Whether to show a button at the end of the input that clears it.

    showTrigger
    boolean
    –

    Whether to show a button at the end of the input that opens the list.

    size
    number|"lg"|"sm"|"default"
    –

    The size of the component.

    startAddon
    ReactNode
    –

    Decorative content, such as an icon, shown at the start of the input. It is hidden from screen readers.

    triggerIcon
    ReactNode
    –

    Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

    triggerProps
    AutocompleteTriggerProps
    –

    Props for the open button, such as aria-label or className.

    CommandItem

    Accepts className, style and render, plus every native attribute of the element it renders.

    PropTypeDefaultDescription
    children
    ReactNode
    –

    The content of the component.

    disabled
    boolean
    false

    Whether the component should ignore user interaction.

    index
    number
    –

    The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.

    nativeButton
    boolean
    false

    Whether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.

    onClick
    ((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)
    –

    An optional click handler for the item when selected. It fires when clicking the item with the pointer, as well as when pressing Enter with the keyboard if the item is highlighted when the Input or List element has focus.

    value
    any
    null

    A unique value that identifies this item.

    CommandList

    Accepts className, style and render, plus every native attribute of the element it renders.

    PropTypeDefaultDescription
    children
    ReactNode | ((item: any, index: number) => ReactNode)
    –

    The content of the component.

    CommandPanel

    Accepts render, plus every native <div> attribute.

    CommandSeparator

    Accepts className, style and render, plus every native attribute of the element it renders.

    PropTypeDefaultDescription
    orientation
    "horizontal"|"vertical"
    'horizontal'

    The orientation of the separator.

    CommandShortcut

    Accepts render, plus every native <kbd> attribute.

    Helpers

    CommandCreateHandle is called, not rendered. It creates a handle: pass it as handle to a trigger and to the root, and the trigger can sit anywhere in the tree, outside the root.

    /
    undefined
    to do nothing.