CommandPalette

A Cmd+K / Ctrl+K command palette for keyboard-quick navigation. Opens a searchable dialog over the page. Nested items are flattened to leaf nodes automatically.

Import

import { CommandPalette } from '@adjanour/react-components'
import '@adjanour/react-components/command-palette.css'

Live Example

Press the keyboard shortcut, start typing to filter, arrow keys to navigate, Enter to select.

Usage

const items = [
  { title: 'Home', path: '/' },
  {
    title: 'Projects',
    children: [
      { title: 'Active', path: '/projects/active' },
      { title: 'Archived', path: '/projects/archived' },
    ],
  },
]

export default () => <CommandPalette items={items} />

With React Router

<CommandPalette
  items={navItems}
  renderLink={(item, children) => (
    <NavLink to={item.path!}>{children}</NavLink>
  )}
/>

Custom Messages

<CommandPalette
  items={items}
  placeholder="Type to search..."
  emptyMessage="No matching pages"
/>

Props

PropTypeDefaultDescription
itemsAccordionItemType[]RequiredItems (nesting flattened)
renderLink(item, children) => ReactNode<a>Custom link renderer
placeholderstring'Search...'Input placeholder
emptyMessagestring'No results found'Empty state

Behavior

Theming

VariableDefaultDescription
--aw-cp-overlayrgba(15,23,42,0.4)Backdrop color
--aw-cp-bg#fffDialog background
--aw-cp-radius10pxDialog border radius
--aw-cp-hover#f1f5f9Item hover background
--aw-cp-active-text#1d4ed8Active item text
--aw-cp-muted#64748bMuted text
--aw-cp-border#e2e8f0Borders