or press Ctrl K once you have clicked in here

Code

<!-- glass-command.free.js: download it from the Install section below and host it with your site -->
<script src="/glass-command.free.js" defer></script>

<glass-command placeholder="Type a command or search…" size="44" theme="light">
  <button value="dashboard" data-group="Navigation" data-kbd="G D">Go to dashboard</button>
  <button value="projects" data-group="Navigation" data-kbd="G P">Go to projects</button>
  <button value="invite" data-group="Create" data-hint="Meridian Labs">Invite a teammate</button>
  <button value="theme" data-group="Settings" data-keywords="appearance mode">Switch theme</button>
</glass-command>

<script>
  // opens on ⌘K / Ctrl+K by itself; or call menu.show()
  const menu = document.querySelector('glass-command');
  menu.addEventListener('select', (e) => console.log(e.detail.value));
</script>

In context

or press Ctrl K once you have clicked in here
Type to filter — the matched letters light up
or press Ctrl K once you have clicked in here
A flat list for an editor, Mint Pro

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.

1. Install with one command — or download the file
shadcn CLI · React
npx shadcn@latest add https://www.ui-design.co/r/glass-command.json
2. Load it and use the element
HTML
<!-- glass-command.free.js: download it from the Install section below and host it with your site -->
<script src="/glass-command.free.js" defer></script>

<glass-command placeholder="Type a command or search…" size="44" theme="light">
  <button value="dashboard" data-group="Navigation" data-kbd="G D">Go to dashboard</button>
  <button value="projects" data-group="Navigation" data-kbd="G P">Go to projects</button>
  <button value="invite" data-group="Create" data-hint="Meridian Labs">Invite a teammate</button>
  <button value="theme" data-group="Settings" data-keywords="appearance mode">Switch theme</button>
</glass-command>

<script>
  // opens on ⌘K / Ctrl+K by itself; or call menu.show()
  const menu = document.querySelector('glass-command');
  menu.addEventListener('select', (e) => console.log(e.detail.value));
</script>
3. React + TypeScript (optional)

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:

TypeScript
// glass-command.d.ts
declare namespace JSX {
  interface IntrinsicElements {
    'glass-command': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
      open?: boolean | '';
      query?: string;
      active?: string;
      placeholder?: string;
      shortcut?: string;
      contained?: boolean | '';
      'auto-focus'?: 'true' | 'false';
      width?: number | string;
      'max-height'?: number | string;
      size?: number | string;
      radius?: number | string;
      footer?: 'true' | 'false';
      label?: string;
      theme?: 'light' | 'dark';
      sound?: boolean | '';
    };
  }
}

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

NameTypeDefaultDescription
<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 booleanoffShows 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 booleanoffCovers 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 width560Panel width. It never exceeds the screen.
max-height number (px)348Tallest the list gets before it scrolls.
size number (px)44Row height; type, icons and key caps scale with it.
radius number (px)20Corner 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 booleanoffA 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