Home / Function/ CommandDemo() — ui Function Reference

CommandDemo() — ui Function Reference

Architecture documentation for the CommandDemo() function in command-demo.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  393ca8d7_be99_b1c7_2637_270bdd0da712["CommandDemo()"]
  c8eeb99c_623e_17db_54ef_82551ddcd315["command-demo.tsx"]
  393ca8d7_be99_b1c7_2637_270bdd0da712 -->|defined in| c8eeb99c_623e_17db_54ef_82551ddcd315
  style 393ca8d7_be99_b1c7_2637_270bdd0da712 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/app/(internal)/sink/components/command-demo.tsx lines 24–87

export function CommandDemo() {
  const [open, setOpen] = React.useState(false)

  React.useEffect(() => {
    const down = (e: KeyboardEvent) => {
      if (e.key === "j" && (e.metaKey || e.ctrlKey)) {
        e.preventDefault()
        setOpen((open) => !open)
      }
    }

    document.addEventListener("keydown", down)
    return () => document.removeEventListener("keydown", down)
  }, [])

  return (
    <>
      <p className="text-muted-foreground text-sm">
        Press{" "}
        <kbd className="bg-muted text-muted-foreground pointer-events-none inline-flex h-5 items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 select-none">
          <span className="text-xs">⌘</span>J
        </kbd>
      </p>
      <CommandDialog open={open} onOpenChange={setOpen}>
        <CommandInput placeholder="Type a command or search..." />
        <CommandList>
          <CommandEmpty>No results found.</CommandEmpty>
          <CommandGroup heading="Suggestions">
            <CommandItem>
              <Calendar />
              <span>Calendar</span>
            </CommandItem>
            <CommandItem>
              <Smile />
              <span>Search Emoji</span>
            </CommandItem>
            <CommandItem>
              <Calculator />
              <span>Calculator</span>
            </CommandItem>
          </CommandGroup>
          <CommandSeparator />
          <CommandGroup heading="Settings">
            <CommandItem>
              <User />
              <span>Profile</span>
              <CommandShortcut>⌘P</CommandShortcut>
            </CommandItem>
            <CommandItem>
              <CreditCard />
              <span>Billing</span>
              <CommandShortcut>⌘B</CommandShortcut>
            </CommandItem>
            <CommandItem>
              <Settings />
              <span>Settings</span>
              <CommandShortcut>⌘S</CommandShortcut>
            </CommandItem>
          </CommandGroup>
        </CommandList>
      </CommandDialog>
    </>
  )
}

Subdomains

Frequently Asked Questions

What does CommandDemo() do?
CommandDemo() is a function in the ui codebase, defined in apps/v4/app/(internal)/sink/components/command-demo.tsx.
Where is CommandDemo() defined?
CommandDemo() is defined in apps/v4/app/(internal)/sink/components/command-demo.tsx at line 24.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free