Skip to content

Disclosure

Disclosure

A single expandable section via native <details>.

stableNo JS requiredBuilt on <details>hydrateless/disclosure.css

A single expandable section. Purely CSS via the native <details> element; give several disclosures the same name attribute and the browser itself makes them mutually exclusive. The optional enhancer only adds observable state: an open/setOpen API, an onOpenChange callback, and a bubbling hl:open-change event.

Disclosure

Live
Show more details
This content is revealed when you expand the disclosure. The native details element handles all of the toggling, no JavaScript required.

JavaScript

This component ships an optional enhancer. With auto-init it loads automatically; to wire it yourself, import it directly:

import { enhanceDisclosure } from '@hydrateless/enhancers/disclosure';

const handle = enhanceDisclosure(container, { defaultOpen, onOpenChange });
// handle.api  -> imperative controls
// handle.destroy()  -> tear everything down

Props

The framework bindings expose these props (and forward the rest to the root element).

PropTypeDefaultDescription
summarystringThe visible toggle label (or use the `summary` slot).
openbooleanControlled open state; pair with `onOpenChange`.
defaultOpenbooleanfalseUncontrolled initial open state.
namestringShared group name; the browser closes the other disclosures in the group.

Events and callbacks

Event / CallbackPayloadDescription
hl:open-change{ open: boolean }Fires after the disclosure opens or closes (also the `onOpenChange` callback).

CSS variables

Override these on any ancestor to theme the component. See the theme studio to preview changes live.

CSS variableUsed for
--hl-borderPanel border.
--hl-radius-mdCorner radius.

Accessibility

  • The native <details> summary is a real button with built-in keyboard support.
  • No ARIA is needed for a single disclosure; the element is self-describing.
  • Exclusivity comes from the native name attribute, so it works without JavaScript.

Released under the MIT License.