Disclosure

A headless, accessible disclosure (collapsible) primitive for toggling content visibility.

Features

  • Toggle visibility
  • Controlled or uncontrolled open state
  • Semantic trigger button
  • ARIA-expanded and ARIA-controls wiring
  • Unmounts when closed
  • Headless styling

Installation

npm install @ariaui/disclosure

Examples

Two layouts from the legacy doc: a narrow collapsible list (Heroicons trigger) and a wider playground row (Lucide chevrons). Both use the same Root / Trigger / Content model; style open and closed states with data-[state=open]: utilities.

Collapsible

A compact disclosure: trigger beside a title, with stacked rows inside the panel.

Preview

No preview output yet.

live.tsxReady

Framer Motion

The compact collapsible disclosure animated with Framer Motion through Content asChild composition.

Preview

No preview output yet.

live.tsxReady

Anatomy

tsx
import * as Disclosure from "@ariaui/disclosure";

export default function Example() {
  return (
    <Disclosure.Root>
      <Disclosure.Trigger />
      <Disclosure.Content />
    </Disclosure.Root>
  );
}

API Reference

Root

State container. Owns the open/closed state and provides context to Trigger and Content.

PropTypeDefault
open
boolean
defaultOpen
booleanfalse
onOpenChange
(open: boolean) => void

Trigger

Button that toggles the disclosure open/closed. Renders as a native button element.

AttributeValues
aria-expanded"true" when open, "false" when closed
aria-controlsID of the Content element
typebutton

Content

Container for the collapsible content. Only rendered in the DOM when the disclosure is open.

PropTypeDefault
asChild
booleanfalse

Keyboard

ShortcutAction
EnterToggle the disclosure open/closed when the trigger is focused.
SpaceToggle the disclosure open/closed when the trigger is focused.
TabMove focus to the next focusable element.
Shift+TabMove focus to the previous focusable element.

Accessibility

The Disclosure component implements the WAI-ARIA Disclosure pattern:

  • Trigger renders as a native <button> element with type="button".
  • Trigger carries aria-expanded reflecting the current open/closed state.
  • Trigger carries aria-controls pointing to the Content element's ID.
  • Content is removed from the DOM when closed, making it inaccessible to assistive technologies.
  • Click, Enter, and Space on the trigger all toggle the disclosure state.
Previous
Dialog
Next
Drawer