Disclosure
A section that opens and closes: details most people do not need.
import { Disclosure, DisclosureSkeleton } from '@sypnia/ui/react'
Advanced settings
Closed until someone asks.
Code
import { Disclosure, Field, FormGrid, NumberInput } from '@sypnia/ui/react';
// Details most people do not need stay closed until someone asks for them.
export default function Advanced() {
return (
<Disclosure title="Advanced settings">
<FormGrid>
<Field label="Time limit (seconds)"><NumberInput defaultValue={30} min={1} /></Field>
<Field label="Retries"><NumberInput defaultValue={3} min={0} /></Field>
</FormGrid>
</Disclosure>
);
} In Astro
The twin for static pages, on a native details.
How the price is worked out
Each product has its own plans. Capacity you add is paid with credits, and you see what each credit was spent on.
Code
---
// The Astro twin, for static pages: a native <details>, so it opens with no JavaScript.
import Disclosure from '@sypnia/ui/astro/Disclosure.astro';
---
<Disclosure title="How the price is worked out">
<p>Each product has its own plans. Capacity you add is paid with credits, and you see what each credit was spent on.</p>
</Disclosure> Skeleton
The real piece and its skeleton: the same box, so nothing moves when the data arrives.
Code
import { Disclosure, DisclosureSkeleton } from '@sypnia/ui/react';
export default function Skeleton() {
return (
<div className="sy-stack">
<Disclosure title="Why was this payment refused?">The bank said the card has no funds.</Disclosure>
<DisclosureSkeleton />
</div>
);
} When to use it
Use it when
- Advanced settings, an explanation, a long detail.
Do not use it when
- It holds something everyone needs: show it.
- Several of them in a row: Accordion.
For everyone
- The title is a button that says whether it is open.
- The Astro twin (
@sypnia/ui/astro/Disclosure.astro) is a nativedetails: Enter or Space opens it with no JavaScript, and find in page opens it when the text is inside.
Props
| Disclosure | Type | Default |
|---|---|---|
titlerequired | ReactNode | |
defaultOpen | boolean |