Details

A reveal and a height transition for <details>. Each press flips open immediately, like the native element; the animation follows.

Live example: ink, then dissolve
Ink

The cover recedes from the top with an organic edge, like ink soaking into paper.

Dissolve

Fractal noise, top to bottom, with a glowing edge. This is the default effect.

Live example: an exclusive accordion (name="faq")
Shipping

Orders leave the warehouse within two days.

Opening another row closes this one.

Returns

Thirty days, no questions asked.

Usage

<details>
  <summary>Title</summary>
  <div class="content">Content</div>
</details>
import { createRenderer, createDetailsFx, inkEffect } from 'webgl-ui'

const renderer = createRenderer()
const fx = createDetailsFx(document.querySelector('details')!, { renderer, effect: inkEffect })

// later, e.g. when a component unmounts
fx.destroy()

The details needs a <summary> and one content element after it. The canvas is placed inside the content element, so give it a background: the cover is painted in that color.

Options

OptionTypeDefaultDescription
rendererRenderer | () => RendererrequiredThe shared renderer.
effectEffectDefdissolveEffectAny effect: built-in, defineGlslEffect or defineTslEffect.
durationnumber800Opening in ms; closing takes 70%. A reversal halfway takes the remaining share.
contentHTMLElementfirst child after the summaryThe element that is revealed.
trace(message) => voidnoneDebug hook for internal decisions.

Returns

MemberDescription
destroy()Settles a running animation, removes the listeners. The details stays where it was.
debug(){ open, target, running, progress }, for tests and devtools.

CSS hooks

HookWhereMeaning
[data-animating]detailsPresent while an animation runs.
--pdetailsProgress, 0 (closed) to 1 (open), the same value the shader receives.
--fx-covercontent (inherited)Cover color as r, g, b (0..255). Default: the content background.

Two recipes use these: fade and blur the content and soften the clip edge.

Behavior and accessibility

Full table: native parity, details. Stress test: playground.