Q3 roadmap.pdfEdited 2 hours ago

Code

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

<glass-menu size="36" label="File" theme="light">
  <button slot="trigger">Options</button>
  <button value="rename" data-icon="pen" data-kbd="⌘ R">Rename</button>
  <button value="duplicate" data-icon="copy" data-kbd="⌘ D">Duplicate</button>
  <button value="pin" data-icon="pin" data-checked>Pin to sidebar</button>
  <div data-label="Move to" data-icon="folder">
    <button value="move:design">Design</button>
    <button value="move:archive">Archive</button>
  </div>
  <hr>
  <button value="delete" data-icon="trash" data-danger>Delete</button>
</glass-menu>

<script>
  document.querySelector('glass-menu').addEventListener('select', (e) => {
    console.log(e.detail.value, e.detail.checked);
  });
</script>

In context

Q3 roadmap.pdfEdited 2 hours ago
Right-click anywhere on this card
A context menu — right-click the card
Mira OkaforMeridian Labs
Mint, compact rows, aligned to the end 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-menu.json
2. Load it and use the element
HTML
<!-- glass-menu.free.js: download it from the Install section below and host it with your site -->
<script src="/glass-menu.free.js" defer></script>

<glass-menu size="36" label="File" theme="light">
  <button slot="trigger">Options</button>
  <button value="rename" data-icon="pen" data-kbd="⌘ R">Rename</button>
  <button value="duplicate" data-icon="copy" data-kbd="⌘ D">Duplicate</button>
  <button value="pin" data-icon="pin" data-checked>Pin to sidebar</button>
  <div data-label="Move to" data-icon="folder">
    <button value="move:design">Design</button>
    <button value="move:archive">Archive</button>
  </div>
  <hr>
  <button value="delete" data-icon="trash" data-danger>Delete</button>
</glass-menu>

<script>
  document.querySelector('glass-menu').addEventListener('select', (e) => {
    console.log(e.detail.value, e.detail.checked);
  });
</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-menu.d.ts
declare namespace JSX {
  interface IntrinsicElements {
    'glass-menu': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
      open?: boolean | '';
      context?: boolean | '';
      align?: 'start' | 'end';
      active?: string;
      label?: string;
      size?: number | string;
      width?: number | 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 (items, trigger, context, onSelect, onOpen / onClose) 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
slot="trigger" attribute on one child—The element that opens the menu — usually your own <button>. It gets aria-haspopup, aria-expanded and aria-controls, and focus returns to it when the menu closes.
<button value> children—The items. data-icon names a built-in icon (pen, copy, link, folder, share, download, star, pin, eye, user, archive, trash, plus, out) or put your own <svg> inside; data-kbd shows a shortcut hint; data-danger makes it red; data-checked (or data-checked="false") makes it a switchable item with a tick; disabled greys it out. An <hr> is a separator.
<div data-label> child with buttons inside—A submenu, one level deep: data-label is its row in the menu (data-icon works too) and the buttons inside are its items. It slides out on hover, Enter or the right arrow.
context booleanoffA context menu: no trigger — it opens at the pointer on a right-click (or the Menu key) anywhere in the parent element.
align 'start' | 'end''start'Which edge of the trigger the menu lines up with. It still flips to the other edge, or above the trigger, when it would leave the viewport.
open booleanoffHolds the menu open for a preview or a screenshot: it ignores outside presses and never flips. For normal use call el.show() / el.hide() and listen to open and close.
active string—Value of the item to highlight; an item inside a submenu opens that submenu. Lets a script drive a preview.
size number (px)36Row height; type, icons and corners scale with it.
width number (px)220Min width of the menu. It grows with its longest item.
label string—Accessible name of the menu.
theme 'light' | 'dark''light'White or dark glass.
sound booleanoffA glass clink on open, close and select. Also on for everything inside an element with data-ui-sound="on".
tint Pro'aurora' | 'sunset' | 'mint' | 'mono' | object'aurora'Colours of the light along the top edge, the highlight and the tick, or a custom tint. Free build ships Aurora only.

It fires select with detail.value (and detail.checked for a switchable item, which flips itself), plus open and close. The keyboard follows the menu pattern: the arrows, Home and End walk the items, typing a letter jumps to the item that starts with it, Enter or Space chooses, the right and left arrows open and close the submenu, Escape steps back one level, and Tab or a press outside closes it. Focus returns to the trigger — or, for a context menu, to whatever had it. The menu is positioned next to its trigger, not in a portal, so keep it out of ancestors with overflow: hidden; each panel has its own backdrop blur, which is the only costly part. Shortcut hints are labels only — bind the keys yourself. On touch screens a context menu depends on the browser’s long-press, so give those users a visible button as well. The children are read once, when the element connects; replace them later with el.items = […].

More components