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 (
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
| Name | Type | Default | Description |
|---|---|---|---|
| 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 | boolean | off | A 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 | boolean | off | Holds 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) | 36 | Row height; type, icons and corners scale with it. |
| width | number (px) | 220 | Min 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 | boolean | off | A 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
- Glass Toast
- Glass Sheet
- Glass Tip
- Tide Slide
- Pearl Code
- Ink Sphere
- Frost Card
- Holo Card
- Stream Text
- Lens Compare
- Pearl Dial
- Nova Rating
- Pearl Check
- Pearl Input
- Pearl Select
- Pearl Accordion
- Pearl Calendar
- Glass Nav
- Pearl Tabs
- Glass Command
- 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 Tabbar
- Pearl Pricing
- Glass Bento
- Quote Wall
- Glass Cta
- Magnet Button
- Beam Border
- Spotlight Card
- Scratch Reveal
- Glass Sidebar
- Pearl Pagination
- Pearl Breadcrumb
- 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