Home / Function/ CommandDialogDemo() — ui Function Reference

CommandDialogDemo() — ui Function Reference

Architecture documentation for the CommandDialogDemo() function in command-dialog.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  4d749c8a_5e6c_3d2c_07b6_5caba92ba457["CommandDialogDemo()"]
  38c8787f_bc96_533c_614a_e312f7dc3c6b["command-dialog.tsx"]
  4d749c8a_5e6c_3d2c_07b6_5caba92ba457 -->|defined in| 38c8787f_bc96_533c_614a_e312f7dc3c6b
  style 4d749c8a_5e6c_3d2c_07b6_5caba92ba457 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/new-york-v4/examples/command-dialog.tsx lines 24–87

export default function CommandDialogDemo() {
  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 CommandDialogDemo() do?
CommandDialogDemo() is a function in the ui codebase, defined in apps/v4/registry/new-york-v4/examples/command-dialog.tsx.
Where is CommandDialogDemo() defined?
CommandDialogDemo() is defined in apps/v4/registry/new-york-v4/examples/command-dialog.tsx at line 24.

Analyze Your Own Codebase

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

Try Supermodel Free