Command Menu with Keyboard Shortcuts
blocks/command-menu-02FreeBlock
A command menu with keyboard shortcuts block.
Install it
npx shadcn@latest add https://blocks.so/r/command-menu-02.jsonSource
1'use client';23import {4 IconArrowRight,5 IconAt,6 IconCopy,7 IconDeviceDesktop,8 IconDownload,9 IconFile,10 IconFileSearch,11 IconKeyboard,12 IconLink,13 IconLogout,14 IconMessage,15 IconPencil,16 IconPlus,17 IconSend,18 IconSettings,19 IconTemplate,20 IconUser,21 IconUsers,22} from '@tabler/icons-react';23import { useEffect, useState } from 'react';24import { Button } from '@/components/ui/button';25import {26 Command,27 CommandEmpty,28 CommandGroup,29 CommandInput,30 CommandItem,31 CommandList,32} from '@/components/ui/command';33import {34 Dialog,35 DialogContent,36 DialogDescription,37 DialogHeader,38 DialogTitle,39} from '@/components/ui/dialog';40import { Kbd, KbdGroup } from '@/components/ui/kbd';4142export function CommandMenu02() {43 const [open, setOpen] = useState(true);44 const [inputValue, setInputValue] = useState('');4546 useEffect(() => {47 const down = (e: KeyboardEvent) => {48 if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {49 e.preventDefault();50 setOpen((prev) => !prev);51 }52 };5354 document.addEventListener('keydown', down);55 return () => document.removeEventListener('keydown', down);56 }, []);5758 return (59 <>60 <Button onClick={() => setOpen(true)} variant="outline">61 Open Command Menu62 </Button>6364 <Dialog onOpenChange={setOpen} open={open}>65 <DialogHeader className="sr-only">66 <DialogTitle>Command Menu</DialogTitle>67 <DialogDescription>68 Use the command menu to navigate through the app.69 </DialogDescription>70 </DialogHeader>71 <DialogContent72 className="gap-0 overflow-hidden rounded-xl border-border/50 p-0 shadow-lg sm:max-w-lg"73 showCloseButton={false}74 >75 <Command className="flex h-full w-full flex-col overflow-hidden bg-popover **:data-[slot=command-input-wrapper]:h-auto **:data-[slot=command-input-wrapper]:grow **:data-[slot=command-input-wrapper]:border-0 **:data-[slot=command-input-wrapper]:px-0">76 <div className="flex h-12 items-center gap-2 border-border/50 border-b px-4">77 <CommandInput78 className="h-10 text-[15px]"79 onValueChange={setInputValue}80 placeholder="What do you need?"81 value={inputValue}82 />83 <button84 className="flex shrink-0 items-center"85 onClick={() => setOpen(false)}86 type="button"87 >88// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from blocks
All 76 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AI Chat with Voice Inputai-01 | blocks | Blocks | Free | 1 dep | |
| AI Chat with Model Selectionai-02 | blocks | Blocks | Free | 1 dep | |
| AI Chat Compact Interfaceai-03 | blocks | Blocks | Free | 1 dep | |
| AI Chat with File Attachmentsai-04 | blocks | Blocks | Free | 1 dep | |
| AI Elements Chatai-05 | blocks | Blocks | Free | 2 deps | |
| Command Menu with Groupscommand-menu-01 | blocks | Blocks | Free | 1 dep | |
| Command Menu with Documentation Searchcommand-menu-03 | blocks | Blocks | Free | 1 dep | |
| Dialog Confirmationdialog-01 | blocks | Blocks | Free | 1 dep |
