Skip to content

Components

Dropdown Menu

A menu of actions that swells out of the control that opens it as one body of glass: a button of its own, or a whole Button Group.

Latest changeFixedv1.6.11With over, an icon on the control (the three dots of a Button Group, an icon beside a label) now comes back with the letters, out of the same blur and dark, instead of fading in on its own ahead of them.
  1. v1.6.11FixedWith over, an icon on the control (the three dots of a Button Group, an icon beside a label) now comes back with the letters, out of the same blur and dark, instead of fading in on its own ahead of them.
  2. v1.6.11FixedWith over, the list no longer has its corners cut off while the surface is still round: it shrinks a little more until it fits inside the glass.
  3. v1.6.11ImprovedThe light of the press that opens a surface spills past its edge as a much fainter glow, on every popup.
  4. v1.6.11ImprovedWith over, the content no longer leaves the surface empty and white while it goes back in: it shrinks with the glass and fades over 0.24 s, nearly to the end.
  5. v1.6.8ImprovedWith over="center", the menu closes the same softer way and the button's label comes back letter by letter. over="edge" is new: the menu grows from the button's own edge. The new from prop picks whether it comes down from above (the default) or up from below.
  6. v1.6.8FixedThe soft close now ends still: once the surface is back in, the button no longer swells and settles for a moment. It showed most on a small button, such as the three dots of a Button Group. Popover closes the same way.
  7. All changes →
glass-dropdown-menu-basic.tsx

Use it for

  • A handful of actions on one thing, kept out of the way until asked for: Rename, Duplicate, Delete.
  • The overflow of a Button Group: the three dots at its end.

Not for

  • Picking a value that stays selected: use Select.
  • Two or three actions that fit on screen: show them in a Button Group.
  • Several of these on one screen: one stretching list is a moment, many are noise.

Installation

npx shadcn@latest add https://onemorethink.dev/r/dropdown-menu.json

The behaviour (keyboard, typeahead, focus, positioning, ARIA) comes from UI SDK, so Dropdown Menu needs @ui-sdk/core and @ui-sdk/react. The install command adds them at the exact version this was built on: UI SDK is in beta and its API may still change.

Usage

app.tsx
import {
  GlassDropdownMenu,
  GlassDropdownMenuContent,
  GlassDropdownMenuItem,
  GlassDropdownMenuSeparator,
  GlassDropdownMenuTrigger,
} from '@/components/liquid-glass/glass-dropdown-menu'

<GlassDropdownMenu over="center">
  <GlassDropdownMenuTrigger>Options</GlassDropdownMenuTrigger>
  <GlassDropdownMenuContent>
    <GlassDropdownMenuItem onSelect={rename}>Rename</GlassDropdownMenuItem>
    <GlassDropdownMenuItem onSelect={duplicate}>Duplicate</GlassDropdownMenuItem>
    <GlassDropdownMenuSeparator />
    <GlassDropdownMenuItem destructive onSelect={remove}>Delete</GlassDropdownMenuItem>
  </GlassDropdownMenuContent>
</GlassDropdownMenu>

With over="center" on GlassDropdownMenu, the button itself unfolds into the menu, which settles around it with the button in its middle: Popover's opening. over="edge" grows it from the button's own edge instead, and from="bottom" brings it up from below where it comes down from above by default. Closing folds it back into the button. The menu stays where it is instead of flipping, so keep the button away from the top and bottom of the screen. The trigger wears Button's clear glass, so it needs something behind it to bend.

Opening on a neck

Leave over out for Select's motion: the list swells out of the whole trigger, the neck between them stretches and snaps, and the items arrive one after another; closing plays it backwards. It flips when there is no room.

A list that stretches out of its button
glass-dropdown-menu-stretch.tsx

Out of a Button Group

Wrap one group and the content in the menu, and put the trigger on one of the group's items with asChild. The whole group is then the anchor: the menu comes out of its body and takes its colour, white included. Wrap only the group that opens the menu.

toolbar.tsx
<GlassDropdownMenu over="center">
  <GlassButtonGroup>
    <GlassDropdownMenuTrigger asChild>
      <GlassButtonGroupItem aria-label="More" className="px-0"><Ellipsis /></GlassButtonGroupItem>
    </GlassDropdownMenuTrigger>
  </GlassButtonGroup>
  <GlassDropdownMenuContent>
    <GlassDropdownMenuItem>Mark as read</GlassDropdownMenuItem>
    <GlassDropdownMenuItem destructive>Delete</GlassDropdownMenuItem>
  </GlassDropdownMenuContent>
</GlassDropdownMenu>
The three dots of a toolbar
glass-dropdown-menu-group.tsx

API reference

PropTypeDefault
open / defaultOpen / onOpenChange

On GlassDropdownMenu: control the menu yourself, or let it keep its own state.

boolean / boolean / (open: boolean) => void—
over

On GlassDropdownMenu: the button unfolds into the menu. center: the menu settles around it. edge: it grows from the button's own edge, away from it. Left out, the list swells out of the control on a neck.

'center' | 'edge'—
from

On GlassDropdownMenu, with over: which way the menu comes into place. top: the button is thrown down and the menu comes down from above. bottom: the other way up.

'top' | 'bottom''top'
GlassDropdownMenuTrigger asChild

Put the trigger on its single child (a GlassButtonGroupItem) instead of a glass button of its own.

booleanfalse
GlassDropdownMenuContent side / align

Where the list opens against the trigger: below and centred by default. It flips when there is no room.

'top' | 'bottom' / 'start' | 'center' | 'end''bottom' / 'center'
GlassDropdownMenuContent sideOffset

The gap between the control and the list, where the neck stretches. With over="center", passing it places the menu yourself.

number12
GlassDropdownMenuItem onSelect

Runs when the item is pressed; the menu then closes (closeOnSelect={false} keeps it open).

() => void—
GlassDropdownMenuItem destructive

Paints the item red, for Delete.

booleanfalse
GlassDropdownMenuItem disabled

Dimmed and skipped by the keyboard.

booleanfalse
GlassDropdownMenuSeparator

A hairline between items.

className—

Accessibility

  • A button with aria-haspopup that opens a menu of menuitems (the WAI-ARIA menu button pattern).
  • Arrow keys, Home and End move through the items, typing a letter jumps to a match, Enter runs the item, Escape closes and returns focus to the trigger.
  • An icon-only trigger needs an aria-label.
  • With reduced motion the list opens and closes at once. Without WebGL2 it is a plain frosted list.