0.1.0

Disclosure

Disclosures progressively reveal content behind a trigger, such as FAQs, filter panels, or advanced settings that most users can skip.

Try it

Delivered in 3–5 business days.

Usage

Use RuiDisclosureTrigger and RuiDisclosurePanel inside RuiDisclosure. Group related disclosures with RuiDisclosureGroup when only one should be open.

import {
  RuiDisclosure,
  RuiDisclosureTrigger,
  RuiDisclosurePanel,
} from '@ecopages/radiant-ui/disclosure';
 
<RuiDisclosure>
  <RuiDisclosureTrigger>Shipping details</RuiDisclosureTrigger>
  <RuiDisclosurePanel>Delivered in 3–5 business days.</RuiDisclosurePanel>
</RuiDisclosure>

RuiDisclosureTrigger renders an indicator arrow defaulting to RuiIconChevronDown. It points downward when collapsed and rotates 180° when expanded.

Set iconPosition="end" to position the arrow at the trailing edge (default is "start"). Pass iconPosition and icon directly to RuiDisclosure when using the trigger prop, or configure them on RuiDisclosureTrigger. Pass icon={<RuiDisclosureIcon variant="plus" />} or icon={null} to customize.

Indicator position

Place the toggle arrow at the start or trailing end using iconPosition="end".

Items can be returned within 30 days of delivery.
import { RuiDisclosure } from '@ecopages/radiant-ui/disclosure';
 
<RuiDisclosure trigger="Return policy" iconPosition="end">
  Items can be returned within 30 days of delivery.
</RuiDisclosure>

Custom markup

<rui-disclosure> coordinates any light-DOM tree that matches its query contract. The Rui* helpers stamp these targets; they are not required.

import '@ecopages/radiant-ui/disclosure';
 
<rui-disclosure>
  <div class="rui-disclosure">
    <button type="button" data-disclosure-trigger class="rui-disclosure__trigger">
      Shipping details
    </button>
    <div data-disclosure-panel class="rui-disclosure__panel">
      <div class="rui-disclosure__panel-inner">Delivered in 3–5 business days.</div>
    </div>
  </div>
</rui-disclosure>

BEM classes are presentation-only. Do not set aria-expanded, aria-controls, hidden, or data-state — the host owns those.

Accordion groups

Wrap multiple disclosures in RuiDisclosureGroup with multiple=\{false} for accordion behavior.

Delivered in 3–5 business days.
Free returns within 30 days.
Email [email protected] for help.
import '@ecopages/radiant-ui/disclosure';
 
<rui-disclosure-group>
  <rui-disclosure>
    <button type="button" data-disclosure-trigger>Shipping</button>
    <div data-disclosure-panel hidden>Delivered in 3–5 days.</div>
  </rui-disclosure>
</rui-disclosure-group>

Animated panels

Enable animated for height transitions. Verify content remains readable during the animation.

Theming

Disclosure surfaces map to semantic surface roles, never Tailwind palette steps:

PartCSS roles
Trigger (rui-disclosure__trigger)on-background; hover / focus surface, --focus-ring
Panel (rui-disclosure__panel)on-surface
Group (rui-disclosure-group)background, border, rounded-container; panel header surface

Override roles at the theme layer, not in component CSS.

API

Disclosure provides two custom elements: <rui-disclosure> (show/hide) and <rui-disclosure-group> (accordion). Compose the view helpers to render triggers and panels, or mark up data-disclosure-trigger / data-disclosure-panel elements directly.

Attributes (<rui-disclosure>)

AttributeTypeDefaultDescription
openbooleanfalseWhether the disclosure content starts expanded.
valuestring''Optional value used when coordinating disclosures inside a group.
animatedbooleanfalseAnimate panel height; also enabled inside an animated group.

Light-DOM contract (<rui-disclosure>)

TargetRequiredHost writesAuthor owns
[data-disclosure-trigger]yesaria-expanded, aria-controlsthe trigger element
[data-disclosure-panel]yesid, data-state, hidden, aria-hidden (when animated)panel content

Do not set aria-expanded, aria-controls, hidden, or data-state. Nested hosts: none.

Attributes (<rui-disclosure-group>)

AttributeTypeDefaultDescription
multiplebooleanfalseAllow more than one disclosure open (exclusive by default).
animatedbooleanfalseAnimate panel height for child disclosures.

Light-DOM contract (<rui-disclosure-group>)

TargetRequiredHost writesAuthor owns
rui-disclosureyesanimated propagatedone section per child
[data-disclosure-trigger]yes (in each child)roving tabIndex across grouptrigger inside each rui-disclosure

Nested host: rui-disclosure — owns [data-disclosure-trigger] and [data-disclosure-panel].

Events

EventDetailDescription
rui-disclosure-toggle{ value, open }Emitted on every trigger activation; groups listen for exclusive behavior.

View helpers

ComponentTarget stampedNotes
RuiDisclosure<rui-disclosure> + [data-ref="root"] shelltrigger prop composes trigger + panel; accepts icon and iconPosition.
RuiDisclosureGroup<rui-disclosure-group> + [data-ref="root"] shellExpects rui-disclosure children.
RuiDisclosureTrigger[data-disclosure-trigger]Includes chevron down icon by default; accepts icon and iconPosition.
RuiDisclosureIcon—Presentation only; renders RuiIconChevronDown by default.
RuiDisclosurePanel[data-disclosure-panel]Wraps content in rui-disclosure__panel-inner.

CSS classes

Public BEM classes on the composed light-DOM surface (documented via @cssclass):

ClassDescription
.rui-disclosureRoot wrapper around trigger and panel regions.
.rui-disclosure__triggerTrigger button; reflects aria-expanded.
.rui-disclosure__trigger--icon-endLayout when iconPosition="end".
.rui-disclosure__iconIndicator wrapper (decorative, aria-hidden).
.rui-disclosure__icon--chevronRotates 180° when open.
.rui-disclosure__icon--plusToggles between + and ×.
.rui-disclosure__labelTrigger text.
.rui-disclosure__panelPanel content region.
.rui-disclosure__panel-innerPanel padding wrapper (drives the height animation).
.rui-disclosure-groupGroup surface (bordered card around stacked disclosures).

Theme roles

PartCSS variables consumed
Trigger--on-background, --surface (hover), --focus-ring, --space-control-*
Panel--on-surface
Group--background, --border, --surface

Accessibility

  • Triggers expose aria-expanded reflecting panel visibility.
  • Panel content is associated with its trigger via aria-controls.
  • Keyboard users activate disclosures with Enter or Space on the trigger.