Skip to content

Components

AccordionUpdated

A list of glass pills that each open into a card: the pill grows in width and height into a card with its content while the others make room, and up and down buttons step from card to card. A block of tiles that part is its other form.

Latest changeImprovedv2.3.4Accordion is now a list of glass pills that each expand into a card: the pill grows in width and height over 0.45 s while the others make room, its label leaves and the content rises in. GlassAccordionPrevious and GlassAccordionNext step from card to card without closing one, GlassAccordionClose or Escape hands the card back to its pill, and focus follows the card. The items now go inside GlassAccordionList. The motion and the behaviour are those of Chánh Đại's Apple Accordion (MIT), on UI SDK's accordion and the kit's engine.
  1. v2.3.4ImprovedAccordion is now a list of glass pills that each expand into a card: the pill grows in width and height over 0.45 s while the others make room, its label leaves and the content rises in. GlassAccordionPrevious and GlassAccordionNext step from card to card without closing one, GlassAccordionClose or Escape hands the card back to its pill, and focus follows the card. The items now go inside GlassAccordionList. The motion and the behaviour are those of Chánh Đại's Apple Accordion (MIT), on UI SDK's accordion and the kit's engine.
  2. v2.3.4ImprovedThe block of tiles that part is still here, as variant="tiles". Unchanged otherwise: add the prop to an accordion you already have to keep it as it was.
  3. v2.3.3FixedAccordion no longer hitches on a mid-range phone. A tap made every tile picture the page behind it again at once, the tiles did it several more times after they had come to rest, and a tile whose answer wrapped to more lines ran out of its picture half way and took another. Now nothing is pictured while the tiles move: a tile reads the picture it has, with room above and below only and twice as much of it, a sticky header nearby no longer counts as the page having moved, and once every tile is at rest they take their new pictures one at a time. Its canvas grows in steps instead of on every frame, and scrolling past an accordion draws nothing. On a phone-sized page with the processor slowed six times, four toggles went from 84 pictures of the page to 16, all of them after the motion, and from 11 frames later than 34 ms to 1. The motion and the look are unchanged.
  4. v2.3.3FixedA tile's glass is drawn on the frame its tile changes. The springs ran on a loop of their own, after the glass had drawn, so the glass showed the height and the corners of the frame before: for a moment it was shorter than its opening tile and taller than its closing one. They now run on the engine's frame, before it draws.
  5. v2.3.1FixedAccordion no longer stutters as it opens and closes. Every tile pictured the whole page behind it again on each frame of the spring, four tiles at a time. Now a tile takes that picture once, a little wider than itself, and reads from it while it moves; it takes another only when it comes to rest or travels past it. The motion and the look are unchanged.
  6. v2.3.0NewAccordion: a block of glass tiles that part to let one open. The tile steps 10 px away from its neighbours and its corners round, with the corners that face it; its height opens on a spring that goes a little past its size, and sinks as far under it when it closes, while the answer clears from a blur. The tiles wear the glass of Dialog's pane. One item or several open, bounce={false} for a height that only settles, and hiddenUntilFound so find in page can open an answer. The open items, the keyboard, the headings and ARIA come from UI SDK.
  7. All changes →
glass-accordion-basic.tsx

Use it for

  • A short list of things to look at one at a time, each with a few lines to say: the five pillars of Islam, the features of a product on a landing page, the steps of a tour beside a picture.
  • Questions and answers, the sections of a settings page, the details of an order: use the tiles (variant="tiles").

Not for

  • Switching between views of the same thing, where one is always shown: use Tabs.
  • Actions, or a value to pick: use Menu, Dropdown Menu or Select.
  • Content everyone needs to read: do not hide it behind a press.

Installation

npx shadcn@latest add https://liquidglass.onemorethink.dev/r/accordion.json

The behaviour (which items are open, the keyboard, the headings, ARIA, find in page) comes from UI SDK, so Accordion 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 {
  GlassAccordion,
  GlassAccordionClose,
  GlassAccordionContent,
  GlassAccordionItem,
  GlassAccordionList,
  GlassAccordionNext,
  GlassAccordionPrevious,
  GlassAccordionTrigger,
} from '@/components/liquid-glass/glass-accordion'

<GlassAccordion>
  <GlassAccordionPrevious />
  <GlassAccordionNext />

  <GlassAccordionList>
    <GlassAccordionItem value="salah">
      <GlassAccordionTrigger>Salah</GlassAccordionTrigger>
      <GlassAccordionContent>Five prayers a day, facing the Kaaba.</GlassAccordionContent>
    </GlassAccordionItem>
    <GlassAccordionItem value="sawm">
      <GlassAccordionTrigger>Sawm</GlassAccordionTrigger>
      <GlassAccordionContent>The fast of Ramadan, from dawn until sunset.</GlassAccordionContent>
    </GlassAccordionItem>
  </GlassAccordionList>

  <GlassAccordionClose />
</GlassAccordion>

Closed, every item is a pill as wide as its label. Press one and it grows into a card over 0.45 s (0.3 s with tempo="quick", shrinking back in 0.25 s), width and height together, while the pills above and below make room. Its label leaves at once; the content arrives once the card has room for it, rising a little. Press another pill and the two change places. The motion is that of Chánh Đại's Apple Accordion (MIT), written on the engine's frame so each pill's glass is drawn at the size the pill has on that frame.

A card is closed by Escape, by GlassAccordionClose, or by opening another: its own label is gone while it is open. GlassAccordionPrevious and GlassAccordionNext open the item above or below without closing the card, and skip disabled items. The three buttons show only while a card is open and are yours to place, with classes; leave them out if you do not need them. The items go inside GlassAccordionList, and a card is at most 400 px wide and never wider than the accordion less 80 px. value and onValueChange say which card is open (a list, as UI SDK keeps it), to show something beside the list that goes with it.

The pills wear the glass of everything that opens over the page, Dialog's pane among them: a 60% tint (white, or black on a dark page), a 10 px frost and a rim that bends the page close to the edge. So put the accordion over something: a picture, a coloured section, a page of text. tint, blur and optics on GlassAccordion set your own, and the text follows the tone of the glass.

Tiles

A block of tiles that part (variant="tiles")
glass-accordion-tiles.tsx

It begins at dawn, with the call to the fajr prayer, and ends at sunset, with the call to maghrib.

variant="tiles" is the accordion for questions and answers. Its items are the accordion's own children, with no list and no buttons. Closed, the tiles lie against each other as one block: only its outer corners are round. Press a question and its tile steps 10 px away from its neighbours, all four of its corners round, and the corners that face it round with them. Its height opens on a spring that goes about a tenth past its size and settles; closing, it sinks as far under its rest height and comes back. The answer clears from a 2 px blur as it fades in. Pressing the open tile closes it, and bounce={false} lets the height settle without going past its size.

faq.tsx
<GlassAccordion variant="tiles" defaultValue={['hours']}>
  <GlassAccordionItem value="hours">
    <GlassAccordionTrigger>When does the fast begin and end?</GlassAccordionTrigger>
    <GlassAccordionContent>From dawn until sunset.</GlassAccordionContent>
  </GlassAccordionItem>
  <GlassAccordionItem value="fitr">
    <GlassAccordionTrigger>What is zakat al-fitr?</GlassAccordionTrigger>
    <GlassAccordionContent>A charity given before the Eid prayer.</GlassAccordionContent>
  </GlassAccordionItem>
</GlassAccordion>

More than one open

One item is open at a time. multiple lets several stay open: each pill is its own card, and each open tile stands apart. collapsible={false} keeps one item open at all times. value and onValueChange control it; the value is always a list of the open items.

settings.tsx
const [open, setOpen] = useState(['profile'])

<GlassAccordion variant="tiles" multiple value={open} onValueChange={setOpen}>
  <GlassAccordionItem value="profile">…</GlassAccordionItem>
  <GlassAccordionItem value="billing">…</GlassAccordionItem>
  <GlassAccordionItem value="team" disabled>…</GlassAccordionItem>
</GlassAccordion>

Content the page can find

Closed content leaves the page. keepMounted keeps it in the HTML, hidden, so a crawler that runs no script still reads it; hiddenUntilFound also lets the browser's find in page match its text, and the item opens when it does. Set either on GlassAccordion for every item, or on one GlassAccordionContent.

Speed: the preview above has a Default / Quick switch. Quick plays Emil Kowalski's timings; the default is the speed the glass was made with. Set it on one component with tempo, or for the whole page once with setGlassTempo('quick'); the prop wins over the page. Nothing extra to install.

API reference

PropTypeDefault
tempo

On GlassAccordion: quick: a card opens in 0.3 s and closes in 0.25 instead of 0.45, and the tiles move on a stiffer spring (Emil Kowalski's timings). Left out: the page's tempo (setGlassTempo), else default, the speed it was made with.

'default' | 'quick''default'
variant

Pills that each open into a card, or a block of tiles that part to let one open.

'pills' | 'tiles''pills'
value / defaultValue / onValueChange

On GlassAccordion: the values of the open items. Control them yourself, or let the accordion keep its own state.

string[] / string[] / (value: string[], details) => void—
multiple

Whether several items can be open at once.

booleanfalse
collapsible

Whether the open item can close. false keeps one open.

booleantrue
disabled

Stops every item from opening or closing. On GlassAccordionItem: that item.

booleanfalse
bounce

Tiles: whether the height goes a little past its size before it settles.

booleantrue
tint / blur / optics

The glass, as on Card: how much tint covers the page, how much it is frosted (px), and the fine-tuning.

number / number / GlassOptics0.6 / 10.25
keepMounted / hiddenUntilFound

Keep closed content in the page, hidden; let find in page open it. Also on GlassAccordionContent, for one item.

booleanfalse
controller

From createAccordionController(): opens, closes and toggles items from anywhere (open(value), closeAll()).

AccordionController—
GlassAccordionList className

Pills: the column the items stand in (flex flex-col items-start gap-3).

string—
GlassAccordionItem value

Names the item in the accordion's value; the up and down buttons step only to items that have one. onOpenChange runs before it opens or closes.

string—
GlassAccordionItem className

Classes for the pill (its corners are 28 px; its size belongs to the motion) or for the tile (px-6 by default; its 18 px corners and the 10 px around an open tile belong to the motion).

string—
GlassAccordionTrigger / GlassAccordionContent className

Classes for the label (a pill's: h-14 ps-3.5 pe-8 text-base font-medium) and for the content (a card's: p-7 text-base).

string—
GlassAccordionPrevious / Next / Close

Pills: the kit's own GlassButton, as 36 px discs. className places them, aria-label names them in your language (default Previous, Next, Close), and children replaces the icon.

button props—

Accessibility

  • Every label is a <button> inside a heading (h3), with aria-expanded and aria-controls; its content is a region named by the label.
  • Pills: focus moves into the card as it opens, and Escape or Close returns it to the pill. The up and down buttons keep focus, so pressing one again keeps stepping; at an end they are aria-disabled, not removed.
  • Tiles: Tab moves from question to question; Enter and Space open and close.
  • Closed content is out of the page, or hidden with keepMounted, so it is never read or focused while closed.
  • With reduced motion a card or a tile takes its size at once and the content only fades. Without WebGL2 the pills and the tiles are plain frosted panels.

Liquid Glass is built and maintained by one person. If it saves you time, you can sponsor the work.