Select
A select whose list swells out of its button as one body of glass, holds on by a neck that stretches and snaps, and closes by the same motion played backwards.
Latest changeFixedv1.6.1Opening a Select no longer shows a faint square around its control. While the list swells out, the control's glass and the list's are two canvases that meet along the control's box; they overlapped by a pixel, and by more while the control was still swollen from the hover, so the shadow there was drawn twice. They now meet on one line and draw in the same space.
- v1.6.1FixedOpening a Select no longer shows a faint square around its control. While the list swells out, the control's glass and the list's are two canvases that meet along the control's box; they overlapped by a pixel, and by more while the control was still swollen from the hover, so the shadow there was drawn twice. They now meet on one line and draw in the same space.
- v1.5.4ImprovedChoosing an option lights the glass around that option only, and the light leaves with the list: a list on its way back into the button is no longer lit whole. Pressing the button to close the list lights the button alone. Dropdown Menu gets the same.
- v1.5.3ImprovedPressing the button lets light into the glass where the press lands. The light paints nothing: it brightens the glass's own colour; it lights the glass around that spot evenly, the near end of the list included, stays inside the button but spills a little past the edge of the open list, spreads and fades. Opened from the keyboard, it starts at the button's centre. The press that opens the list carries its light into it: the light grows with the list until it covers it whole, then fades. Presses that land before the last light has faded add up, so it grows brighter the more you press. Choosing an option lights the list where it lands, more softly. Dropdown Menu does the same. The list is now one surface from start to finish: it leaves the button already wearing the card's glass and the card's shadow, instead of the button's glass turning into a card once the neck lets go.
- v1.5.3ImprovedThe list closes faster, and the bridge between the button and the list is thinner. Dropdown Menu gets the same.
- v1.5.2FixedOpening no longer stutters. The page behind the glass is uploaded once per opening instead of on every frame, the popup measures the page once per frame instead of after each of its own style writes, and it no longer reads its colours and sizes again while the list comes in. The drawing loop also stops once the motion has died out, where it used to run for seconds after. Closing is lighter too: it uploaded the page some twenty times as the button settled, and now does so once, when the motion ends. Dropdown Menu gets the same.
- v1.5.0ImprovedThe button now swells under the pointer and grows when pressed, as Button does. The neck thins more slowly before it snaps, and the snap no longer throws the button or the list out of place. The bridge no longer raises a ridge on the far edge of a small control, and small controls get a tighter bridge of their own. The label sways with the glass, and once the list is back inside, the button swells as if hovered and lets go.
- All changes →
Use it for
- Picking one option from a short list that should stay out of the way until asked for.
- A form field: the value is submitted under
name.
Not for
- Two to five options that fit on one line: use Tabs.
- An on/off setting: use Switch.
- Several of these on one screen: one stretching list is a moment, a form full of them is noise.
Installation
npx shadcn@latest add https://onemorethink.dev/r/select.jsonThe behaviour (keyboard, typeahead, focus, positioning, ARIA) comes from UI SDK, so Select 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
import { GlassSelect } from '@/components/liquid-glass/glass-select'
const [speed, setSpeed] = useState<string | null>(null)
<GlassSelect
label="Delivery"
placeholder="Choose a speed"
value={speed}
onValueChange={setSpeed}
options={[
{ value: 'standard', label: 'Standard' },
{ value: 'express', label: 'Express' },
{ value: 'pickup', label: 'Pickup', disabled: true },
]}
/>Opening, the list swells out of the whole button, the neck between them stretches and snaps, both halves take the jolt and the options arrive one after another. Closing is the opening played backwards, frame for frame; reopen it on the way and it carries on from there. The button wears Button's glass, with its light and shadow. Once the neck lets go, the list settles into Card's frost with no light of its own: a thin line draws its edge and a soft shadow lifts it off the page. The glass is clear, so it needs something behind it to bend.
Your own popup
The stretch is not tied to a select. GlassPopup, which ships with it, puts the same motion on any control and the surface it opens (a menu, a popover):
import { GlassPopupAnchor, GlassPopupSurface, useGlassPopup } from '@/components/liquid-glass'
const popup = useGlassPopup()
<MenuTrigger data-glass-host className="rounded-full px-5 h-12 bg-white/60 dark:bg-white/10">
<GlassPopupAnchor popup={popup} />
Options
</MenuTrigger>
<MenuContent data-glass-popup data-glass-skip sideOffset={12} className="rounded-3xl p-1.5">
<GlassPopupSurface popup={popup} />
<div role="menu">
<MenuItem style={{ '--glass-i': 0 }}>Rename</MenuItem>
<MenuItem style={{ '--glass-i': 1 }}>Duplicate</MenuItem>
</div>
</MenuContent>GlassPopupAnchoris the first child of the control (markeddata-glass-host);GlassPopupSurfaceis the first child of the content (markeddata-glass-popup).- The content carries
data-openwhile open anddata-ending-stylewhile it closes, and stays mounted until its animations finish: UI SDK's popups do this. - Items are
role="option",role="menuitem"ordata-glass-item;--glass-iis each one's place in the queue. - The surface takes its corners from the content's own
rounded-*class; leave about 12 px between it and the control for the neck.
API reference
| Prop | Type | Default |
|---|---|---|
labelThe field's label, tied to the button. | ReactNode | — |
optionsThe choices, in order. | { value: string; label: ReactNode; disabled?: boolean }[] | — |
valueThe selected value (controlled). | string | null | — |
defaultValueThe starting value when the select keeps its own state. | string | null | — |
onValueChangeCalled with the new value. | (value: string | null) => void | — |
placeholderShown on the button while nothing is selected. | string | — |
nameSubmits the value with a form under this name. | string | — |
disabledDimmed and not interactive. | boolean | false |
classNameClasses for the field (label and button); it is 16rem wide by default. | string | — |
useGlassPopup({ matchWidth })Your own popup: keep the surface exactly as wide as its control. | boolean | false |
Accessibility
- A
comboboxbutton that opens alistbox(the WAI-ARIA select pattern), labelled bylabel. - Arrow keys, Home and End move through the options, typing a letter jumps to a match, Enter selects, Escape closes and returns focus to the button. Disabled options are skipped.
- With reduced motion the list opens and closes at once, with no stretch or jolt.
- Without WebGL2 it is a plain frosted list.