Disclosure
A button that shows and hides one block of content.
Example
Webhook retries: 3
<focsd-disclosure summary="Show advanced options" ><p>Webhook retries: 3</p></focsd-disclosure>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-disclosure.js';</script>
<focsd-disclosure summary="Show advanced options">…</focsd-disclosure>import { Disclosure } from '@focsd-dev/react';
export function Example() { return <Disclosure onToggle={(e) => console.log(e.target)} summary="Show advanced options">…</Disclosure>;}<script setup>import '@focsd-dev/components/focsd-disclosure.js';</script>
<template> <focsd-disclosure @toggle="onChange" summary="Show advanced options">…</focsd-disclosure></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-disclosure.js';
// template<focsd-disclosure (toggle)="onChange($event)" summary="Show advanced options">…</focsd-disclosure><script> import '@focsd-dev/components/focsd-disclosure.js';</script>
<focsd-disclosure ontoggle={(e) => console.log(e.target)} summary="Show advanced options">…</focsd-disclosure>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
summary | summary | string | — |
open | open | boolean | false |
disabled | disabled | boolean | false |
name | name | string | — |
Methods
| Method | Description |
|---|---|
toggle() | Open or close the panel (does nothing while disabled); toggle fires once it has. |
Events
| Event | Description |
|---|---|
toggle | Fired when the element opens or closes. Like <details>, it does not bubble. |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
icon | Replaces the expand indicator (keep it decorative). |
CSS parts
Style the inside of the component with ::part(), for example focsd-disclosure::part(icon).
| Part | Description |
|---|---|
icon | The icon element. |
panel | The panel element. |
trigger | The trigger element. |
Accessibility
namemakes disclosures in the same tree an exclusive group: opening one closes the others, like<details name>.- A
<button aria-expanded aria-controls>and its panel in one shadow root. - Fires
togglewhen it opens or closes.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Toggle |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.