Layout
Disclosure A single collapsible section that shows or hides content when a trigger is activated.
npm pnpm yarn bun
npm install @morphos/layout
import { Disclosure, DisclosureTrigger, DisclosureContent } from '@morphos/layout'
@ Component ()
class MyComponent extends StatefulComponent {
@ State () disclosure = new Disclosure ({ defaultOpen: false })
render () {
return (
< Disclosure disclosure = { this .disclosure}>
< DisclosureTrigger disclosure = { this .disclosure}>
Show details
</ DisclosureTrigger >
< DisclosureContent disclosure = { this .disclosure}>
< p >This content is revealed when the trigger is activated.</ p >
</ DisclosureContent >
</ Disclosure >
)
}
}
Disclosure, DisclosureTrigger, and DisclosureContent are also exported as Collapsible, CollapsibleTrigger, and CollapsibleContent — they are the exact same classes, just re-exported under alternate names for consumers who prefer that naming.
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@morphos/layout'
Component Description DisclosureRoot state manager — controls open state DisclosureTriggerThe button that toggles content visibility DisclosureContentThe collapsible content area
Prop Type Default Description openboolean— Controlled open state defaultOpenbooleanfalseInitial open state (uncontrolled) onOpenChange(open: boolean) => void— Called when open state changes classstring— CSS class idstring— HTML id
Method Description toggle()Toggles the disclosure open/closed
Prop Type Default Description disclosureDisclosure— The Disclosure state instance childrenChildren— Trigger label classstring— CSS class idstring— HTML id aria-labelstring— Accessible label when trigger text is not descriptive
Prop Type Default Description disclosureDisclosure— The Disclosure state instance childrenChildren— Content to reveal classstring— CSS class idstring— HTML id (defaults to the disclosure's generated content id)
Attribute Element When present data-openDisclosure, DisclosureTrigger, DisclosureContent Content is visible
DisclosureContent uses the native hidden attribute to hide content when closed, which removes it from the accessibility tree and prevents focus from reaching hidden elements.
.morphos-disclosure-trigger [ data-open ] ::before {
transform : rotate ( -135 deg );
}