Command
A versatile component for searching, filtering, and executing commands or actions.
View component sourceImport
import { Command } from '@app-studio/components';New to the library? Complete installation and provider setup first.
Interactive examples
Try the component, then open Code to copy the complete example.
import React, { useState } from 'react';
import { Command } from '@app-studio/components';
import { Button } from '@app-studio/components';
import { HomeIcon, SettingsIcon, UserIcon, InfoIcon, SearchIcon } from '@app-studio/components';
export const DefaultCommand = () => {
const [open, setOpen] = useState(false);
const commands = [
{
id: 'home',
name: 'Home',
description: 'Go to home page',
icon: <HomeIcon widthHeight={16} />,
shortcut: '⌘H',
onSelect: () => console.log('Home selected'),
},
{
id: 'settings',
name: 'Settings',
description: 'Open settings page',
icon: <SettingsIcon widthHeight={16} />,
shortcut: '⌘S',
onSelect: () => console.log('Settings selected'),
},
{
id: 'profile',
name: 'Profile',
description: 'View your profile',
icon: <UserIcon widthHeight={16} />,
shortcut: '⌘P',
onSelect: () => console.log('Profile selected'),
},
{
id: 'help',
name: 'Help',
description: 'Get help and support',
icon: <InfoIcon widthHeight={16} />,
shortcut: '⌘?',
onSelect: () => console.log('Help selected'),
},
{
id: 'search',
name: 'Search',
description: 'Search for content',
icon: <SearchIcon widthHeight={16} />,
shortcut: '⌘K',
onSelect: () => console.log('Search selected'),
},
];
return (
<>
<Button onClick={() => setOpen(true)}>Open Command Palette</Button>
<Command
open={open}
onOpenChange={setOpen}
commands={commands}
placeholder="Search commands..."
/>
</>
);
};Props
Required props are marked below. A dash indicates an unspecified default. Design system configuration can override implementation defaults.
Scroll horizontally to see every column.
| Prop | Type | Default | Description |
|---|---|---|---|
open Required | boolean | — | See the type and source declaration for this property.Source |
onOpenChange Required | (open: boolean) => void | — | See the type and source declaration for this property.Source |
groups | CommandGroup[] | — | See the type and source declaration for this property.Source |
commands | CommandItem[] | — | See the type and source declaration for this property.Source |
placeholder | string | — | Hint displayed while the field is empty.Source |
size | CommandSize"sm""md""lg" | — | Size preset for the component.Source |
variant | CommandVariant"outline""default""filled" | — | Visual treatment of the component.Source |
filter | ((value: string, item: CommandItem) => boolean) | — | See the type and source declaration for this property.Source |
emptyState | View typestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | — | See the type and source declaration for this property.Source |
footer | View typestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | — | See the type and source declaration for this property.Source |
views | CommandStyles | — | Style overrides for the named internal parts.Source |
Command.Input
Scroll horizontally to see every column.
| Prop | Type | Default | Description |
|---|---|---|---|
value Required | string | — | Current controlled value. Update it from the matching change callback.Source |
onValueChange Required | (value: string) => void | — | Called when the selected value changes.Source |
placeholder | string | — | Hint displayed while the field is empty.Source |
views | { container?: ViewProps; input?: ViewProps; } | — | Style overrides for the named internal parts.Source |
Command.List
Scroll horizontally to see every column.
| Prop | Type | Default | Description |
|---|---|---|---|
children Required | View typestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | — | Content rendered inside the component.Source |
views | { container?: ViewProps; } | — | Style overrides for the named internal parts.Source |
Command.Group
Scroll horizontally to see every column.
| Prop | Type | Default | Description |
|---|---|---|---|
heading Required | string | — | See the type and source declaration for this property.Source |
children Required | View typestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | — | Content rendered inside the component.Source |
views | { container?: ViewProps; heading?: ViewProps; } | — | Style overrides for the named internal parts.Source |
Command.Item
Scroll horizontally to see every column.
| Prop | Type | Default | Description |
|---|---|---|---|
item Required | CommandItem | — | See the type and source declaration for this property.Source |
selected | boolean | — | See the type and source declaration for this property.Source |
onSelect | (() => void) | — | See the type and source declaration for this property.Source |
views | { container?: ViewProps; icon?: ViewProps; content?: ViewProps; name?: ViewProps; description?: ViewProps; shortcut?: ViewProps; } | — | Style overrides for the named internal parts.Source |
Command.Empty
Scroll horizontally to see every column.
| Prop | Type | Default | Description |
|---|---|---|---|
children | View typestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | — | Content rendered inside the component.Source |
views | { container?: ViewProps; } | — | Style overrides for the named internal parts.Source |
For shared layout, color, and responsive properties, read Styling & composition and Responsive layouts. Additional native element attributes depend on the target platform.
Usage guidance
- Give controls a visible label or an accessible name, and verify keyboard interaction. See Accessibility.
- For controlled inputs, update the value from the callback shown in the props table. Keep application state in your component or form library.
- These previews run in the browser. Check React Native setup for platform requirements and differences.