This documentation is under construction. Pages can be missing or change at any time. Follow it on GitHub.

Skip to content

Collapsible

A collapsible panel controlled by a button.

Examples#

Hidden until found#

The hiddenUntilFound prop hides the closed panel with hidden="until-found" so the browser can search its contents with find-in-page—Ctrl+F (Cmd+F on macOS)—and reveal the panel when a match is found. The closed panel always remains in the DOM, which also makes its contents indexable by search engines.

Older browsers that don’t support hidden="until-found" keep the panel hidden until its trigger opens it, and find-in-page skips over the contents.

API reference#

Import the components of the family:

use Phem\Ui\Collapsible;
use function Phem\Ui\{CollapsibleTrigger, CollapsiblePanel};

Collapsible#

A section that opens and closes: Base UI Collapsible.Root, on the phem-collapsible controller.

PropTypeDefault
defaultOpenboolfalse
disabledboolfalse
children?Htmlnull
...attrsarray[]

CollapsibleTrigger#

The button that opens and closes the panel. It has a caret that turns when the panel is open.

PropTypeDefault
children?Htmlnull
...restmixed—

CollapsiblePanel#

The panel. Its height animates with --collapsible-panel-height. With hiddenUntilFound, the closed panel has hidden="until-found": the search of the browser (Ctrl+F) finds its text and opens it.

PropTypeDefault
hiddenUntilFoundboolfalse
children?Htmlnull
...restmixed—

The source of the examples: examples/ui/Collapsible.phem.

Phem
Esc
↑↓ to navigate↵ to openEsc to close