Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Command for Svelte

A command palette for Svelte on Ark UI: a search field that narrows a list of actions as you type, with groups, shortcut hints and a dialog.

On this page9 sections
UI library: Ark UI

Command puts a search field above a list of actions. People type a few letters, the list narrows to the rows that match, and Enter runs the highlighted one. Open it in a dialog on Cmd+K as an app-wide command palette, or keep it inline at the top of a sidebar or a menu.

When the pick is a value a form keeps, such as a country or an assignee, use a Combobox. A short menu with nothing to search reads better as a Dropdown Menu.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Command anatomy: root, input, group label, list, item, shortcut

Usage

import { useListCollection } from "@ark-ui/react/collection";
import { useFilter } from "@ark-ui/react/locale";
import {
  Command, CommandContent, CommandEmpty, CommandInput, CommandItem,
  CommandList,
} from "@/components/ui/command";

Command doesn't filter on its own. It shows the collection you pass, so narrow that collection whenever the search changes, in onInputValueChange.

const items = [
  { label: "Calendar", value: "calendar" },
  { label: "Search Emoji", value: "emoji" },
  { label: "Calculator", value: "calculator" },
];

const CommandMenu = () => {
  const { contains } = useFilter({ sensitivity: "base" });
  const { collection, filter } = useListCollection({
    filter: contains,
    initialItems: items,
  });

  return (
    <Command
      className="max-w-sm rounded-lg border"
      collection={collection}
      onInputValueChange={(details) => filter(details.inputValue)}
    >
      <CommandInput placeholder="Type a command or search..." />
      <CommandContent>
        <CommandList>
          <CommandEmpty>No results found.</CommandEmpty>
          {collection.items.map((item) => (
            <CommandItem item={item} key={item.value}>
              {item.label}
            </CommandItem>
          ))}
        </CommandList>
      </CommandContent>
    </Command>
  );
};

Accessibility

Focus stays in the search field while the arrow keys move a highlight through the list, and the field points at the highlighted row with aria-activedescendant, so a screen reader reads each row as it's reached. The field has the combobox role and the list is a listbox of options, named "Suggestions". CommandInput takes its accessible name from its placeholder, or "Search" without one. CommandDialogContent gives the dialog a title only screen readers hear, "Command Palette" unless you set title. The icons are decoration, so keep them aria-hidden as the demos do.

Arrow Down
Highlights the next item, and stays on the last one unless you set loopFocus on Command.
Arrow Up
Highlights the previous item, and stays on the first one unless you set loopFocus on Command.
Home
Highlights the first item.
End
Highlights the last item.
Enter
Picks the highlighted item and clears the search field.
Escape
In CommandDialog, closes the palette.

Demos

Basic

An Open Menu button opens a dialog with three suggestions, Calendar, Search Emoji and Calculator, under a field that narrows them as you type. A short message takes the rows' place when nothing matches. Start here for a palette over a few actions, or leave out the dialog to keep the list on the page, like the menu at the top.

Preview width

Shortcuts

Profile, Billing and Settings, each with an icon and a CommandShortcut at the end of the row showing ⌘P, ⌘B or ⌘S. The hint is text, and nothing in this demo listens for those keys. Show hints when the actions already have shortcuts elsewhere in your app, so the palette teaches them, and bind the keys yourself.

Preview width

Groups

Suggestions and Settings sit under their own headings with a separator between them, an icon on every row and shortcut hints on the settings rows. Each item names its group, groupBy in useListCollection reads that field, and collection.group() returns the sections. Group the commands once they fall into more than one kind, such as places to go and things to do.

Preview width

Scrollable

Twenty-three commands in five groups, from Navigation and Actions down to Account and Tools, more than the dialog can show at once. The list stops at 18rem and scrolls with its scrollbar hidden, while the search field stays at the top. At this length a few typed letters beat scrolling, and the headings help the people who scroll anyway.

Preview width

Palette

Cmd+K on a Mac or Ctrl+K elsewhere toggles the palette from anywhere on the page, and a Search button opens it for pointer and touch users. Pages and Actions are grouped, and a footer names the keys for moving, picking and closing. Picking a row writes its name under the button and closes the dialog, which is the wiring an app-wide palette needs.

Preview width

RTL

The inline menu from the top of the page in Arabic, with dir set to rtl on both Command and CommandInput. Headings, labels, the placeholder and the empty message are translated, the calculator row stays disabled, and the shortcut hints move to the inline end of each row, on the left. Use it to check the filter and the separators in a right-to-left layout.

Preview width

FAQ

How do I open the Command palette with Cmd+K in Svelte?

Listen for the shortcut on document yourself, because the component binds no keys of its own. In the keydown handler, check that the key is k and that metaKey or ctrlKey is down, call preventDefault() so the browser doesn't act on the keys too, and flip the open state you pass to CommandDialog.

Add the listener when the component mounts and remove it when it unmounts. The Palette demo does exactly this, and keeps a Search button on the page for phones, where there is no shortcut to press.

How do I run an action when a Command item is selected?

Handle onSelect on Command. It fires on every pick, by click or Enter, with the row's value in details.itemValue. The Palette demo uses onValueChange instead, with value held at an empty array so that picking the same row twice still fires, and reads the whole item from details.items.

Navigating works the same way: go to the route in that handler, then close the dialog so the page underneath is what people see.

Should I use a Command or a Combobox?

Use a Command when picking a row does something: it opens a page, runs an action or flips a setting, the way a command palette or a searchable action menu works. The search is a way to reach the action, and nothing needs to remember which row was chosen.

Use a Combobox when the pick is a value that stays in a form field afterwards, like a country or an assignee, and goes out with the form when it's submitted.

How do I change how the Command filters and ranks items?

Ark UI leaves filtering to you: Command shows the collection you pass, and the demos narrow it with useListCollection. Its filter option decides what matches, here contains from useFilter, which ignores case and accents and tests each item's label.

Swap in startsWith from the same hook, or write a function that also reads the item, its third argument, to match on aliases. Items stay in the order you gave them, since nothing is ranked.

How do I load Command results from an API as the user types?

Fetch in onInputValueChange on Command, then put the response in the collection with set from useListCollection, which replaces the items. Leave out the hook's filter option so the server's results show as they come back.

Debounce the request so each keystroke doesn't start a new one. CommandEmpty shows whenever the collection is empty, so render a loading row while the first request is in flight.

Why doesn't pressing a Command shortcut do anything?

CommandShortcut is a label and nothing more. It prints the keys at the end of the row, but no code listens for them, in the palette or anywhere else.

Bind each one yourself with a keydown listener on document, the way the Palette demo binds Cmd+K, and have it call the same function the row runs when it's picked. Keeping both in one place stops a hint from naming keys that do something else.

How do I show a message when no Command results match?

Put a CommandEmpty inside CommandList. It renders only while the collection you pass is empty, which is what your filter produces when nothing matches, and without children it says "No results found." Give it your own words, such as a hint to try another term or a link to the full search.

API Reference

Command

<div> data-slot="command"

PropType
inputValue?string

The controlled value of the combobox's input.

defaultInputValue?string

The initial value of the combobox's input when rendered. Use when you don't need to control the value of the combobox's input.

Default
""
onInputValueChange?(details: InputValueChangeDetails) → void

Function called when the input's value changes.

Type
(details: InputValueChangeDetails) → void
Parameters

details – { inputValue: string; reason?: InputValueChangeReason }

Returns
void
open?boolean

The controlled open state of the combobox.

defaultOpen?boolean

The initial open state of the combobox when rendered. Use when you don't need to control the open state of the combobox.

onOpenChange?(details: OpenChangeDetails) → void

Function called when the popup is opened.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean; reason?: OpenChangeReason; value: string[] }

Returns
void
value?string[]

The controlled value of the combobox's selected items.

defaultValue?string[]

The initial value of the combobox's selected items when rendered. Use when you don't need to control the value of the combobox's selected items.

Default
[]
onValueChange?(details: ValueChangeDetails<T>) → void

Function called when a new item is selected.

Type
(details: ValueChangeDetails<T>) → void
Parameters

details – ValueChangeDetails<T>

Returns
void
collectionListCollection<T>

The collection of items.

Type
ListCollection<T>
allowCustomValue?boolean

Whether to allow typing custom values in the input.

alwaysSubmitOnEnter?boolean

Whether to always submit on Enter key press, even if popup is open. Useful for single-field autocomplete forms where Enter should submit the form.

Default
false
autoFocus?boolean

Whether to autofocus the input on mount.

closeOnSelect?boolean

Whether to close the combobox when an item is selected.

Default
false
composite?boolean

Whether the combobox is a composed with other composite widgets like tabs.

Default
true
defaultHighlightedValue?string | null

The initial highlighted value of the combobox when rendered. Use when you don't need to control the highlighted value of the combobox.

Type
string | null
dir?"ltr" | "rtl"

The document's text/writing direction.

Type
"ltr" | "rtl"
Default
"ltr"
disabled?boolean

Whether the combobox is disabled.

disableLayer?boolean

Whether to disable registering this a dismissable layer.

form?string

The associate form of the combobox.

hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
highlightedValue?string | null

The controlled highlighted value of the combobox.

Type
string | null
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the combobox. Useful for composition.

Type
{ root?: string; label?: string; control?: string; input?: string; content?: string; trigger?: string; clearTrigger?: string; item?: (id: string, index?: number) → string; positioner?: string; itemGroup?: (id: string | number) → string; itemGroupLabel?: (id: string | number) → string }
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

inputBehavior?"autohighlight" | "autocomplete" | "none"

Defines the auto-completion behavior of the combobox. - autohighlight: The first focused item is highlighted as the user types - autocomplete: Navigating the listbox with the arrow keys selects the item and the input is updated Ark default: none.

Type
"autohighlight" | "autocomplete" | "none"
Default
autohighlight
invalid?boolean

Whether the combobox is invalid.

lazyMount?boolean

Whether to enable lazy mounting. Ark default: false.

Default
true
loopFocus?boolean

Whether to loop the keyboard navigation through the items. Ark default: true.

Default
false
multiple?boolean

Whether to allow multiple selection. **Good to know:** When multiple is true, the selectionBehavior is automatically set to clear. It is recommended to render the selected items in a separate container.

name?string

The name attribute of the combobox's input. Useful for form submission.

navigate?((details: NavigateDetails) → void) | null

Function to navigate to the selected item.

Type
((details: NavigateDetails) → void) | null
Parameters

(details – { value: string; node: HTMLAnchorElement; href: string }

Returns
void) | null
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

onFocusOutside?(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
onHighlightChange?(details: HighlightChangeDetails<T>) → void

Function called when an item is highlighted using the pointer or keyboard navigation.

Type
(details: HighlightChangeDetails<T>) → void
Parameters

details – HighlightChangeDetails<T>

Returns
void
onInteractOutside?(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
onPointerDownOutside?(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
onSelect?(details: SelectionDetails) → void

Function called when an item is selected.

Type
(details: SelectionDetails) → void
Parameters

details – { value: string[]; itemValue: string }

Returns
void
openOnChange?boolean | ((details: InputValueChangeDetails) → boolean)

Whether to show the combobox when the input value changes.

Type
boolean | ((details: InputValueChangeDetails) → boolean)
Default
true
openOnClick?boolean

Whether to open the combobox popup on initial click on the input.

Default
false
openOnKeyPress?boolean

Whether to open the combobox on arrow key press.

Default
true
placeholder?string

The placeholder text of the combobox's input.

positioning?object

The positioning options to dynamically position the menu.

Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }
Default
{ placement: "bottom-start" }
present?boolean

Whether the node is present (controlled by the user).

readOnly?boolean

Whether the combobox is readonly. This puts the combobox in a "non-editable" mode but the user can still interact with it

required?boolean

Whether the combobox is required.

scrollToIndexFn?(details: ScrollToIndexDetails) → void

Function to scroll to a specific index.

Type
(details: ScrollToIndexDetails) → void
Parameters

details – { index: number; immediate?: boolean; getElement: () → HTMLElement | null }

Returns
void
selectionBehavior?"clear" | "replace" | "preserve"

The behavior of the combobox input when an item is selected - replace: The selected item string is set as the input value - clear: The input value is cleared - preserve: The input value is preserved Ark default: replace.

Type
"clear" | "replace" | "preserve"
Default
clear
skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
translations?object

Specifies the localized strings that identifies the accessibility elements and their states.

Type
{ triggerLabel?: string; clearTriggerLabel?: string }
unmountOnExit?boolean

Whether to unmount on exit. Ark default: false.

Default
true
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-invalid?string

Present when invalid.

data-readonly?string

Present when read-only.

CommandContent

<div>

PropType
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-empty?string

Present when the content is empty.

data-has-nested?string

Present when another listbox is nested inside it.

data-nested?string

Present when it's nested inside another listbox.

data-placementstring

The placement of the content.

data-side"top" | "right" | "bottom" | "left"

The side of the trigger that the content is positioned on.

Type
"top" | "right" | "bottom" | "left"
data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
CSS variableType
--available-heightstring

The height left between the anchor and the viewport's edge.

--layer-indexstring

The index of the dismissable in the layer stack.

--nested-layer-countstring

The number of nested comboboxs.

CommandInput

<input>

PropType
size?InputProps["size"]

The size of the input.

Default
"md"
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-autofocus?string

Present when autoFocus is true.

data-invalid?string

Present when invalid.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

CommandItem

<div> data-slot="command-item"

PropType
itemany

The item to render.

persistFocus?boolean

Whether hovering outside should clear the highlighted state.

asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-highlighted?string

Present when highlighted.

data-state"checked" | "unchecked"

"checked" or "unchecked".

Type
"checked" | "unchecked"
data-valueboolean

The value of the item.

CommandGroup

<div> data-slot="command-group"

PropType
heading?string | Snippet

The heading of the group.

Type
string | Snippet
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-empty?string

Present when the content is empty.

CommandGroupLabel

<div> data-slot="command-group-label"

PropType
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Forwarded to the part.

CommandDialog

PropType
open?boolean

The controlled open state of the dialog.

defaultOpen?boolean

The initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog.

Default
false
onOpenChange?(details: OpenChangeDetails) → void

Function to call when the dialog's open state changes.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean; reason?: OpenChangeReason; value: string[] }

Returns
void
triggerValue?string | null

The controlled active trigger value.

Type
string | null
defaultTriggerValue?string | null

The initial active trigger value when rendered. Use when you don't need to control the active trigger value.

Type
string | null
onTriggerValueChange?(details: TriggerValueChangeDetails) → void

Function to call when the active trigger changes.

Type
(details: TriggerValueChangeDetails) → void
Parameters

details – { value: string | null; triggerElement: HTMLElement | null }

Returns
void
closeOnEscape?boolean

Whether to close the dialog when the escape key is pressed.

Default
true
closeOnInteractOutside?boolean

Whether to close the dialog when the outside is clicked.

Default
true
dir?"ltr" | "rtl"

The document's text/writing direction.

Type
"ltr" | "rtl"
Default
"ltr"
finalFocusEl?() → MaybeElement

Element to receive focus when the dialog is closed.

Returns
MaybeElement
hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the dialog. Useful for composition.

Type
{ root?: string; label?: string; control?: string; input?: string; content?: string; trigger?: string; clearTrigger?: string; item?: (id: string, index?: number) → string; positioner?: string; itemGroup?: (id: string | number) → string; itemGroupLabel?: (id: string | number) → string }
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

initialFocusEl?() → MaybeElement | false

Element to receive focus when the dialog is opened. Return false to skip moving focus, or null to use the default.

Type
() → MaybeElement | false
Returns
MaybeElement | false
lazyMount?boolean

Whether to enable lazy mounting.

Default
false
modal?boolean

Whether to prevent pointer interaction outside the element and hide all content below it.

Default
true
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onEscapeKeyDown?(event: KeyboardEvent) → void

Function called when the escape key is pressed.

Parameters

event – { altKey: boolean; charCode: number; ctrlKey: boolean; code: string; getModifierState: (key: string) → boolean; key: string; keyCode: number; locale: string; location: number; metaKey: boolean; repeat: boolean; shiftKey: boolean; which: number }

Returns
void
onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

onFocusOutside?(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
onInteractOutside?(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
onPointerDownOutside?(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
onRequestDismiss?(event: LayerDismissEvent) → void

Function called when this layer is closed due to a parent layer being closed.

Type
(event: LayerDismissEvent) → void
Parameters

event – LayerDismissEvent

Returns
void
persistentElements?Array<() → Element | null>

Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event

Type
Array<() → Element | null>
present?boolean

Whether the node is present (controlled by the user).

preventScroll?boolean

Whether to prevent scrolling behind the dialog when it's opened.

Default
true
restoreFocus?boolean

Whether to restore focus to the element that had focus before the dialog was opened.

role?"dialog" | "alertdialog"

The dialog's role.

Type
"dialog" | "alertdialog"
Default
"dialog"
skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
trapFocus?boolean

Whether to trap focus inside the dialog when it's opened.

Default
true
unmountOnExit?boolean

Whether to unmount on exit.

Default
false
AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

CommandDialogTrigger

data-slot="command-dialog-trigger"

PropType
value?string

The value that identifies this specific trigger.

asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

CommandDialogContent

<div> data-slot="command-dialog-content"

PropType
bottomStickOnMobile?boolean

Stick the dialog to the bottom of the screen on mobile.

Default
true
description?string

The description of the dialog.

Default
"Search for a command to run..."
positionerClassName?string

Class names on the positioner (the viewport-fixed wrapper).

showCloseButton?boolean

Show close button at the top right corner.

Default
true
size?"2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "fullscreen" | "lg" | "md" | "sm" | "xl"

Ark default: md.

Type
"2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "fullscreen" | "lg" | "md" | "sm" | "xl"
Default
"lg"
title?string

The title of the dialog.

Default
"Command Palette"
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-empty?string

Present when the content is empty.

data-has-nested?string

Present when another listbox is nested inside it.

data-nested?string

Present when it's nested inside another listbox.

data-placementstring

The placement of the content.

data-side"top" | "right" | "bottom" | "left"

The side of the trigger that the content is positioned on.

Type
"top" | "right" | "bottom" | "left"
data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
CSS variableType
--layer-indexstring

The index of the dismissable in the layer stack.

--nested-layer-countstring

The number of nested comboboxs.

CommandList

data-slot="command-list"

PropType
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

CommandEmpty

data-slot="command-empty"

PropType
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

CommandSeparator

data-slot="command-separator"

PropType
class?string

Merged with the part's classes.

AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

CommandShortcut

data-slot="command-shortcut"

PropType
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

CommandFooter

<div> data-slot="command-footer"

PropType
class?string

Merged with the part's classes.

CommandRootProvider

<div> data-slot="command"

PropType
valueUseComboboxReturn<T>

What useCommand() returns: the state and API, made outside the component to control it.

Type
UseComboboxReturn<T>
hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

lazyMount?boolean

Whether to enable lazy mounting. Ark default: false.

Default
true
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

present?boolean

Whether the node is present (controlled by the user).

skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
unmountOnExit?boolean

Whether to unmount on exit. Ark default: false.

Default
true
asChild?Snippet<[PropsFn]>

Render your own element: a snippet that gets the part's props to spread on it.

Type
Snippet<[PropsFn]>
class?string

Merged with the part's classes.

AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

useCommand

CommandContext

CommandItemContext