ComponentsCommand

Command

Fast, composable, unstyled command menu for React.


Demo

import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
  CommandShortcut
} from '@immit/ui/command'
import {
  Calculator,
  Calendar,
  CreditCard,
  Settings,
  Smile,
  User
} from 'lucide-react'
 
export function CommandDemo() {
  return (
    <Command className="border shadow-md">
      <CommandInput placeholder="Type a command or search..." />
      <CommandList>
        <CommandEmpty>No results found.</CommandEmpty>
        <CommandGroup heading="Suggestions">
          <CommandItem className="gap-2">
            <Calendar size={16} />
            <span>Calendar</span>
          </CommandItem>
          <CommandItem className="gap-2">
            <Smile size={16} />
            <span>Search Emoji</span>
          </CommandItem>
          <CommandItem className="gap-2">
            <Calculator size={16} />
            <span>Calculator</span>
          </CommandItem>
        </CommandGroup>
        <CommandSeparator />
        <CommandGroup heading="Settings">
          <CommandItem className="gap-2">
            <User size={16} />
            <span>Profile</span>
            <CommandShortcut>⌘P</CommandShortcut>
          </CommandItem>
          <CommandItem className="gap-2">
            <CreditCard size={16} />
            <span>Billing</span>
            <CommandShortcut>⌘B</CommandShortcut>
          </CommandItem>
          <CommandItem className="gap-2">
            <Settings size={16} />
            <span>Settings</span>
            <CommandShortcut>⌘S</CommandShortcut>
          </CommandItem>
        </CommandGroup>
      </CommandList>
    </Command>
  )
}

Dialog

Press J

'use client'
 
import {
  CommandDialog,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
  CommandShortcut,
  useCommandDialog
} from '@immit/ui/command'
import {
  Calculator,
  Calendar,
  CreditCard,
  Settings,
  Smile,
  User
} from 'lucide-react'
 
export function CommandDialogDemo() {
  const [open, setOpen] = useCommandDialog('j')
 
  return (
    <>
      <p className="text-muted text-sm">
        Press{' '}
        <kbd className="bg-muted text-muted pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium">
          <span className="text-xs">⌘</span>J
        </kbd>
      </p>
      <CommandDialog open={open} onOpenChange={setOpen} title="Search dialog">
        <CommandInput placeholder="Type a command or search..." />
        <CommandList className="w-[500px]">
          <CommandEmpty>No results found.</CommandEmpty>
          <CommandGroup heading="Suggestions">
            <CommandItem className="gap-2">
              <Calendar size={16} />
              <span>Calendar</span>
            </CommandItem>
            <CommandItem className="gap-2">
              <Smile size={16} />
              <span>Search Emoji</span>
            </CommandItem>
            <CommandItem className="gap-2">
              <Calculator size={16} />
              <span>Calculator</span>
            </CommandItem>
          </CommandGroup>
          <CommandSeparator />
          <CommandGroup heading="Settings">
            <CommandItem className="gap-2">
              <User size={16} />
              <span>Profile</span>
              <CommandShortcut>⌘P</CommandShortcut>
            </CommandItem>
            <CommandItem className="gap-2">
              <CreditCard size={16} />
              <span>Billing</span>
              <CommandShortcut>⌘B</CommandShortcut>
            </CommandItem>
            <CommandItem className="gap-2">
              <Settings size={16} />
              <span>Settings</span>
              <CommandShortcut>⌘S</CommandShortcut>
            </CommandItem>
          </CommandGroup>
        </CommandList>
      </CommandDialog>
    </>
  )
}