Command
Use Command to build consistent, accessible interfaces aligned with the shared design system.
Installation
1. Copy the source code:
- Source in this monorepo:
packages/ui/src/components/command.tsx - Place in your project:
components/ui/command.tsx - Required utility:
lib/utils.ts(forcnhelper)
2. Update the import paths to match your project structure.
Usage
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@hoag/ui/components/command";
export default function Demo() {
return (
<Command className="rounded-lg border shadow-sm">
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem>Open Dashboard</CommandItem>
<CommandItem>
Profile
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Settings">
<CommandItem>Notifications</CommandItem>
<CommandItem>Billing</CommandItem>
</CommandGroup>
</CommandList>
</Command>
);
}Import
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@hoag/ui/components/command";Basic Example
No results found.
Open Dashboard
Profile ⌘P
Notifications
Billing
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@hoag/ui/components/command";
export function CommandBasicExample() {
return (
<Command className="rounded-lg border shadow-sm">
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem>Open Dashboard</CommandItem>
<CommandItem>
Profile
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Settings">
<CommandItem>Notifications</CommandItem>
<CommandItem>Billing</CommandItem>
</CommandGroup>
</CommandList>
</Command>
);
}Accessibility Checklist
- Verify semantic roles and ARIA attributes for interactive behavior.
- Keep keyboard navigation and focus visibility consistent in all states.
- Ensure color contrast meets accessibility requirements in light and dark themes.
- Provide screen reader context for dynamic state or content changes.
Testing Checklist
- Add render tests for default and key variant states.
- Add interaction tests for callbacks and state transitions.
- Add visual regression checks for responsive and theme variations.
- Cover edge states such as loading, empty, disabled, and error.
Production Tips
- Wrap component logic in feature-level abstractions for domain behavior.
- Keep visual variants centralized to avoid style drift across screens.
- Reuse a single import path strategy for simpler refactors.
- Mirror documented states in Storybook and QA checklists.
Named Exports
CommandCommandDialogCommandEmptyCommandGroupCommandInputCommandItemCommandListCommandSeparatorCommandShortcut
API Reference
For authoritative prop signatures and implementation details, inspect:
packages/ui/src/components/command.tsx