Skip to Content
NarakUI

Command Bar

A command menu interface for quick actions and navigation.

In a dialog

The usual command bar: a search field over grouped pages and actions. Give DialogContent an aria-label so the dialog has a name, and set inDialog on Command.Root for the larger input and item sizing.

Inline

Command.Root also works without a dialog, for example as a searchable picker inside a card. Pass label to name the list.

Installation

pnpm dlx shadcn@latest add @narakui/command-bar

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/command-bar.json.

Usage

import { Command } from '@/components/ui/command-bar';

<Command.Root>
  <Command.Input placeholder="Search..." />
  <Command.List>
    <Command.Item>Item 1</Command.Item>
    <Command.Item>Item 2</Command.Item>
  </Command.List>
</Command.Root>

Command.Root Properties

PropTypeDefaultDescription
inDialogbooleanfalseUses the larger input, item, and group spacing for a command bar inside a Dialog
labelstring—Accessible label for the command menu. Not shown visibly.
valuestring—Controlled value of the highlighted item
defaultValuestring—Highlighted item value on first render
onValueChange(value: string) => void—Callback fired when the highlighted item changes
shouldFilterbooleantrueSet to false to turn off built-in filtering and sorting, then render matching items yourself
filter(value: string, search: string, keywords?: string[]) => number—Custom match score from 0 (hidden) to 1 (best match)
loopbooleanfalseWraps arrow-key navigation from the last item to the first
classNamestring—Additional CSS classes to apply to the root

Command.Input Properties

PropTypeDefaultDescription
valuestring—Controlled search text
onValueChange(search: string) => void—Callback fired when the search text changes
placeholderstring—Placeholder shown next to the search icon

Command.Item Properties

PropTypeDefaultDescription
onSelect(value: string) => void—Callback fired when the item is chosen by click or Enter
valuestring—Unique value for the item. Inferred from the text content when omitted.
keywordsstring[]—Extra terms to match when filtering
disabledbooleanfalseWhether the command item is disabled
forceMountbooleanfalseAlways renders the item, regardless of filtering

Command.Group Properties

PropTypeDefaultDescription
headingReactNode—Heading rendered above the group's items
valuestring—Unique value for the group. Required when there is no heading.
forceMountbooleanfalseAlways renders the group, regardless of filtering

Other Parts

PartTypeDescription
Command.ListComponentPropsWithoutRef<typeof CommandPrimitive.List>Scrollable container for groups, items, and separators. Caps at 300px tall.
Command.EmptyComponentPropsWithoutRef<typeof CommandPrimitive.Empty>Displayed when no search results are found
Command.SeparatorComponentPropsWithoutRef<typeof CommandPrimitive.Separator>Line between groups. Hidden while searching unless alwaysRender is set.