# Disclosure A component that reveals or hides additional content when toggled. ## Usage Use standalone, or inside `Accordion`. ```svelte Content ``` ## Anatomy The `class` attribute values represent part names. Other attributes represent their corresponding props. ```svelte
{label}
{children}
``` ## Props | Name | Type | Default | Description | |---|---|---|---| | `label*` | `string | Snippet` | - | Trigger label; receives open and variant | | `children*` | `Snippet` | - | Panel content; receives variant | | `open` | `boolean` | `false` | Bindable open/closed state | | `duration` | `number` | `200` | Default slide duration; feeds the default slide params | | `transition` | `DisclosureTransition` | - | Overrides the open/close animation, default slide | | `inactive` | `string | boolean` | - | Soft-disable: reason string via `aria-description`, or `true` without a reason | | `attach` | `Attachment` | - | Svelte attachment on the details element | | `element` | `HTMLDetailsElement` | - | Bindable details element | | `styling` | `SVSClass` | - | Styling override | | `variant` | `SVSVariant` | `NEUTRAL` | Bindable variant | `*` required. Other `HTMLDetailsAttributes` except `name` are passed to `
` via rest props; `class` is merged onto the root. ## Styling To learn more, see [Styling](/docs/styling). ### Variant Management When the details element is closed, `neutral` is applied; when it is open, `active` is applied. If the `variant` prop is specified, the specified value is applied instead of `neutral`. ### Default Class Name `svs-disclosure` ## Accessibility ### ARIA Roles and Attributes The component applies these automatically: - Summary (`label` ``): `aria-disabled="true"` when `inactive` is set, and `aria-description` when `inactive` is a reason string. The managed inactive attributes are component-owned while inactive handling is active; pointer activation is suppressed instead of using a non-native disabled state. ### Standards Basis Disclosure is built on native `
` and `` elements, so keyboard and assistive-technology support follows the browser standard for disclosures. See the [Concepts standards-first guidance](/docs/concepts) for the library's approach. ## Exports ### Types ```ts interface DisclosureProps extends Omit { label: string | Snippet<[boolean, string]>; // Snippet<[open,variant]> children: Snippet<[string]>; // Snippet<[variant]> open?: boolean; // bindable (false) duration?: number; // (200) transition?: DisclosureTransition; inactive?: string | boolean; // reason string (aria-description) OR true for reason-less soft-disable attach?: Attachment; element?: HTMLDetailsElement; // bindable styling?: SVSClass; variant?: SVSVariant; // bindable (VARIANT.NEUTRAL) // other HTMLDetailsAttributes except `name` are passed to
via ...rest; `class` is merged onto root } type DisclosureReqdProps = "label" | "children"; type DisclosureBindProps = "open" | "variant" | "element"; type DisclosureTransition = { fn?: (node: HTMLElement, params: any, options: { direction: "in" | "out" | "both" }) => TransitionConfig; params?: unknown; }; ``` ### Others No additional exports are available. ## Examples The example code uses Tailwind CSS along with `SVSClass`. ### Basic **Code** ```svelte src=DisclosureBasic.svelte Diam facilisi consequat sadipscing in. Illum eleifend sit sit lorem takimata diam ut vel amet elitr duo. ``` ### With Interactive Variant **Code** ```svelte src=DisclosurePract.svelte {#snippet label(open: boolean)} Title {@render icon(open)} {/snippet} Diam facilisi consequat sadipscing in. Illum eleifend sit sit lorem takimata diam ut vel amet elitr duo. {#snippet icon(open: boolean)}
{/snippet} ```