Disclosure

Show or hide a section without destroying its contents.

Usage

<script type="module" src="/assets/components/disclosure/qds-disclosure.js"></script>
<qds-disclosure id="disclosure-main" heading="Operating details" value="operations" expanded region><label>Persistent note <input value="Review production"></label></qds-disclosure>

API and behavior

API Contract
heading / heading slot Visible native button label; fallback Details.
heading-level Semantic heading level 2–6, default 3.
expanded Boolean property/attribute; false hides the persistent panel.
disabled Prevent user toggles; programmatic expansion still works.
region Optional labelled region role. Avoid adding too many landmarks.
value Identity used by an accordion.
toggle() Requests a user-style toggle; returns false if disabled or canceled.
focus(options) Focuses the heading button.

The header button exposes aria-expanded and aria-controls; the panel refers back to the trigger. Enter/Space activate the native button. Closing while focus is inside the panel returns focus to the trigger, including shadow descendants. The default slot stays mounted. CSS parts are heading, trigger, and panel.

qds-before-toggle is cancelable and bubbling/composed; qds-toggle follows a successful user toggle. Both carry { component, expanded, value }. Direct property/attribute changes are silent. Use qds-accordion to coordinate multiple disclosures.

Themes, lifecycle and integration

The component uses native Web Components with an open shadow root, existing QDS CSS custom properties, and no framework runtime. Base CSS is loaded once. Set data-theme="dark" or data-theme="light" on a containing element or use the documentation toolbar. Event listeners and observers are removed on disconnect; reconnecting is supported.

Interactive demo · P0 contracts and verification

Generated Quangular wrappers expose the same attributes/properties and events using the q-qds- prefix. For child composition, use the documented native child elements inside the wrapper when the native parent requires direct children. See the Quangular catalog for generated type signatures.