Code
In context
Install · Free Web Component
One file, no dependencies. Aurora preset, every other option included. Host it yourself so your visitors never load anything from our servers.
The shadcn command adds a typed React wrapper for you. Using the file directly? Custom elements work in React as-is; for type checking add:
Pro · React + TypeScript Pro
One payment of $4.99, yours forever. Use it in unlimited personal and commercial projects; no resale.
- React component (
commands,open/onOpenChange,onSelect) with TypeScript types and the full source - Sunset, Mint and Mono tints, plus custom tints from Brand Fit
- The vanilla Web Component with every tint, a demo page, README and license
Attributes & props
| Name | Type | Default | Description |
|---|---|---|---|
| <button> children | markup | — | One per command: the text is the label, value is what select reports, data-group puts it under a heading, data-hint adds secondary text, data-kbd shows key caps ("G D"), data-keywords adds words the search matches, disabled greys it out. An <svg> inside becomes the icon. |
| commands | property (array) | [] | The same from script: el.commands = [{ value, label, group, hint, kbd, keywords, icon, disabled }]. Set it again any time. |
| open | boolean | off | Shows the menu. Also el.show() and el.hide(). When the user dismisses it the attribute is removed and close fires. |
| shortcut | string | 'mod+k' | Global shortcut that toggles it: mod is Cmd on a Mac and Ctrl elsewhere. Any combination works (ctrl+shift+p, /). none turns it off. |
| placeholder | string | 'Type a command or search…' | Text in the empty search field. |
| query | string | '' | Search text. Setting it replaces what is in the field — to prefill, or to drive a demo. el.query reads what the user typed. |
| active | string | — | Value of the row to highlight; changing it glides the highlight there. |
| contained | boolean | off | Covers the nearest positioned parent instead of the viewport, leaves page scroll alone, and answers the shortcut only while focus is inside that parent. |
| auto-focus | 'true' | 'false' | 'true' | Whether the search field takes focus as the menu opens. Set false for a menu that is open on page load. |
| width | number (px) | CSS width | 560 | Panel width. It never exceeds the screen. |
| max-height | number (px) | 348 | Tallest the list gets before it scrolls. |
| size | number (px) | 44 | Row height; type, icons and key caps scale with it. |
| radius | number (px) | 20 | Corner radius of the panel. |
| footer | 'true' | 'false' | 'true' | The strip of key hints and the result count under the list. |
| label | string | 'Command menu' | Accessible name of the dialog. |
| select / close / query | events | — | select fires with detail.value and detail.label, then the menu closes. close fires when it is dismissed. query fires with detail.query as the user types — use it to load results. |
| theme | 'light' | 'dark' | 'light' | White or dark glass. |
| sound | boolean | off | A glass clink on open and close and a tick as the highlight moves. Also on for everything inside an element with data-ui-sound="on". |
| tint Pro | 'aurora' | 'sunset' | 'mint' | 'mono' | object | 'aurora' | Colours of the light on the top edge, the highlight and the matched letters, or a custom tint. Free build ships Aurora only. |
Arrow keys move the highlight and wrap, Home and End jump, Enter runs, Tab stays inside. Escape clears the search first and closes on the second press. Focus goes to the search field and returns to where it was on close; the page behind stops scrolling. Search is forgiving: nw finds “New invoice”, and results are ranked — a label that starts with the query first, then a word that does, then scattered letters, then keywords. It is a role="dialog" around a combobox and a listbox, so screen readers announce each row as you move. Put it near the end of <body>: an ancestor with a CSS transform or filter would make it cover that ancestor instead of the screen.
More components
- Glass Nav
- Pearl Tabs
- Glass Tabbar
- Glass Sidebar
- Pearl Pagination
- Pearl Breadcrumb
- Tide Slide
- Pearl Code
- Ink Sphere
- Frost Card
- Holo Card
- Stream Text
- Lens Compare
- Pearl Dial
- Nova Rating
- Pearl Check
- Pearl Input
- Glass Toast
- Pearl Select
- Glass Sheet
- Pearl Accordion
- Glass Tip
- Pearl Calendar
- Halo Avatar
- Pearl Steps
- Pearl Skeleton
- Pearl Table
- Pearl Chip
- Pearl Empty
- Roll Counter
- Glass Marquee
- Reveal Text
- Mesh Gradient
- Silk Waves
- Dot Field
- Plasma Orb
- Voice Wave
- Plush Buddy
- Gummy Agent
- Glass Menu
- Pearl Pricing
- Glass Bento
- Quote Wall
- Glass Cta
- Magnet Button
- Beam Border
- Spotlight Card
- Scratch Reveal
- Glass Dock
- Pearl Slider
- Pearl Segmented
- Liquid Metal Button
- Mercury Orb
- Prompt Input
- Voice Orb
- Aurora Ring
- Glass Toggle
- Firefly Button
- Pearl Button
- Pearl Loader
- Alien Face
- Prism Button
- Liquid Carousel
- Orbit Carousel
- Deck Carousel