Navigated to /docs/ui/components/command-menu

CommandMenu

Command palette-style recipe for action discovery.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { CommandMenu } from "@tavojs/ui/command-menu";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/command-menu.

When to use

Use it when

Use `CommandMenu` for command palette style action lists

Choose something else when

Avoid CommandMenu when when a low-level primitive would express a simpler one-off layout more clearly.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

CommandMenu example

TSXCreate: src/components/examples/CommandMenuExample1.tsx
tsximport { CommandMenu } from "@tavojs/ui/command-menu";

export function CommandMenuExample1() {
  return (
    <>
      <CommandMenu items={[{ label: "Documentation", href: "/docs" }, { label: "Settings", href: "/settings" }]} />
    </>
  );
}

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
items{ label: string; description?: string; shortcut?: string; href?: string; disabled?: boolean; onSelect?: () => void }[]

Required

Configures items for this component.
placeholderstring

Configures placeholder for this component.

Complete TypeScript API

Import from @tavojs/ui/command-menu. Published exports: CommandMenu, CommandMenuItem, CommandMenuProps.

CommandMenuProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by CommandMenu.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by CommandMenu.

idstring

No

Inherited id attribute accepted by CommandMenu.

rolestring

No

Inherited role attribute accepted by CommandMenu.

styleRecord<string, unknown>

No

Inherited style attribute accepted by CommandMenu.

titlestring

No

Inherited title attribute accepted by CommandMenu.

tabIndexnumber

No

Inherited tabIndex attribute accepted by CommandMenu.

hiddenboolean

No

Inherited hidden attribute accepted by CommandMenu.

disabledboolean

No

Inherited disabled attribute accepted by CommandMenu.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by CommandMenu.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by CommandMenu.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by CommandMenu.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by CommandMenu.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by CommandMenu.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by CommandMenu.

itemsCommandMenuItem[]

Yes

Configures items for this component.

placeholderstring

No

Configures placeholder for this component.

State ownership and DOM target

ConcernContract
StateNo component state contract is exposed; the application owns the rendered content and surrounding behavior.
DOM targetPublic passthrough props target the component root. Treat nested elements and private class names as implementation details.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Avoid CommandMenu when when a low-level primitive would express a simpler one-off layout more clearly.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Recipes compose lower-level components and inherit their labeling and keyboard expectations.

  • Keep recipe titles descriptive.

  • Use real controls in action slots.

  • Preserve list, table, or form semantics inside the composition.

Component status

ContractCurrent value
Maturitystable
Categoryrecipes
Component import@tavojs/ui/command-menu
Explicit CSS import@tavojs/ui/css/command-menu
PreviewInteractive preview available on this page