CommandMenu
Command palette-style recipe for action discovery.
Preview
A live, theme-aware example rendered with the published component.
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.
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
Choose something else when
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
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.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | 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. |
placeholder | string | — | Configures placeholder for this component. |
Complete TypeScript API
Import from @tavojs/ui/command-menu. Published exports: CommandMenu, CommandMenuItem, CommandMenuProps.
CommandMenuProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by CommandMenu. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by CommandMenu. |
id | string | No | Inherited id attribute accepted by CommandMenu. |
role | string | No | Inherited role attribute accepted by CommandMenu. |
style | Record<string, unknown> | No | Inherited style attribute accepted by CommandMenu. |
title | string | No | Inherited title attribute accepted by CommandMenu. |
tabIndex | number | No | Inherited tabIndex attribute accepted by CommandMenu. |
hidden | boolean | No | Inherited hidden attribute accepted by CommandMenu. |
disabled | boolean | No | Inherited disabled attribute accepted by CommandMenu. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by CommandMenu. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by CommandMenu. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by CommandMenu. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by CommandMenu. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by CommandMenu. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by CommandMenu. |
items | CommandMenuItem[] | Yes | Configures items for this component. |
placeholder | string | No | Configures placeholder for this component. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | No component state contract is exposed; the application owns the rendered content and surrounding behavior. |
| DOM target | Public 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
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | recipes |
| Component import | @tavojs/ui/command-menu |
| Explicit CSS import | @tavojs/ui/css/command-menu |
| Preview | Interactive preview available on this page |