Collapsible
Native details disclosure with controlled or uncontrolled open state.
All components · Theme builder · Implementation source
Live preview
Install
netscript ui:add collapsibleUsage and examples
The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.
import { useState } from 'preact/hooks';
import { Collapsible } from '@app/components/ui/collapsible.tsx';
export function Example() {
const [value, setValue] = useState('standard');
const [open, setOpen] = useState(false);
const [notice, report] = useState('');
return (<><div><Collapsible label="Order details">Ready for fulfillment</Collapsible></div><p role="status">{notice}</p></>);
}Props
Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.
| Owner | Prop | Type | Optional | Description |
|---|---|---|---|---|
CollapsibleProps | label | ComponentChildren | No | |
CollapsibleProps | children | ComponentChildren | No | |
CollapsibleProps | open | boolean | Yes | |
CollapsibleProps | defaultOpen | boolean | Yes | |
CollapsibleProps | onOpenChange | (open: boolean) => void | Yes | |
CollapsibleProps | disabled | boolean | Yes | |
CollapsibleProps | class | string | Yes |
CollapsibleProps extends Omit<JSX.DetailsHTMLAttributes<HTMLDetailsElement>, "open" | "class">Keyboard
| Key | Action |
|---|---|
Enter/Space | Toggle disclosure |
Tokens
Semantic contract roles: space/stack/gap, text/muted, radius/control, state/disabled-opacity.
CSS custom properties referenced directly: --ns-control-gap, --ns-fg, --ns-muted, --ns-radius-control, --ns-ring, --ns-space-1, --ns-space-2, --ns-stack-gap, --ns-text-small, --ns-weight-strong.
Contract and compatibility
Accessibility pattern: WAI-ARIA guidance
- Native details/summary retains no-JavaScript disclosure behavior. After hydration, controlled refusal preserves open and disabled summary prevents activation. Before hydration, native disclosure remains toggleable, including aria-disabled summaries. No global listeners.
Design contract values marked planned are not implementation props. The props above describe what ships today.