collapsible

onChange called 0 time(s)

A button that shows and hides the content below it. The panel stays in the page while it is closed, so find-in-page can still reach this text.
import { collapsible, lucide } from '@markless/ui';export default function CollapsibleBasic() @{	<collapsible.root class="collapsible" open>		<collapsible.trigger class="trigger">			<lucide.chevronright class="trigger-icon" aria-hidden="true" />			What is a collapsible?			<lucide.plus class="trigger-plus" aria-hidden="true" />			<lucide.minus class="trigger-minus" aria-hidden="true" />		</collapsible.trigger>		<collapsible.content class="panel">			A button that shows and hides the content below it. The panel stays in the page while it is			closed, so find-in-page can still reach this text.		</collapsible.content>	</collapsible.root>;}

A collapsible is one button that shows or hides one panel. Use it for a "Show more" section or one question with its answer. For a stack of sections, use accordion.

Anatomy

collapsible anatomy
Anatomy perspectiveFlat
Layers
Project detailsManage settings and collaborators.
collapsible.root

One trigger and one panel that shows or hides.

collapsible.trigger is a native <button>, so Tab reaches it, and Enter and Space press it. It reports aria-expanded and points at the panel with aria-controls.

A closed panel stays in the page

Closing the panel hides it. It does not remove it. So anything inside keeps its state, such as text typed into a field.

A closed panel gets hidden="until-found". The browser's find-in-page still searches it, and a hit opens the panel. onChange runs with true when that happens.

If you set disableUntilFound, a closed panel gets plain hidden instead, and find-in-page skips it.

Styling

The family ships no CSS. It writes these attributes:

Attribute On When
ui-open root, trigger, content The panel is showing.
ui-closed root, trigger, content The panel is hidden.
ui-disabled root disabled is set.

Props on collapsible.root

Prop Type What it does
open boolean Whether the panel starts open. The default is false.
disabled boolean The trigger is disabled, so a press does nothing.
disableUntilFound boolean A closed panel gets plain hidden, so find-in-page skips it.
onChange (open: boolean) => void Called with the new value when the panel opens or closes.

Every other prop goes on the root <div>. Your own onClick on the trigger runs after the panel has changed.