Tinyrack

Collapsible

A single trigger and panel for optional detail, with controlled and uncontrolled state.

Contract

AxisValuesDefault
statecontrolled open or uncontrolled defaultOpenclosed
availabilitydisabledinteractive
lifecycleunmount, keepMounted, or hiddenUntilFoundunmount

Install

pnpm add @tinyrack/ui

Scroll inside the code area to read long lines.

Styles

@import '@tinyrack/ui/components/collapsible.css';

Scroll inside the code area to read long lines.

Imports

import { TRCollapsible } from '@tinyrack/ui/components/collapsible';

Scroll inside the code area to read long lines.

Playground

The Playground keeps open as interaction state rather than a duplicate control. Configure availability, lifecycle, and trigger text; Reset restores the closed, unmounted default.

Usage

Controlled optional details permalink

The visible result updates after pointer, Enter, or Space activation.

Examples

API

TRCollapsible.Root

PropType / defaultPurpose
open / defaultOpenboolean / undefined, falsecontrolled or initial uncontrolled expansion
onOpenChange(open, details) => voidreports trigger and browser-find changes
disabledboolean / falsekeeps the trigger discoverable by focus while blocking state changes
render, className, style, refBase UI root propscustomize the <div> host while preserving behavior

TRCollapsible.Trigger

Renders a button with aria-expanded and aria-controls. It accepts native button props, render, styles, and refs. Enter and Space toggle it while focus remains on the trigger; disabled triggers expose data-disabled and aria-disabled.

TRCollapsible.Panel

Use keepMounted when closed content must remain in the DOM, or hiddenUntilFound to render hidden="until-found" so browser page search can reveal it. hiddenUntilFound takes precedence when both are supplied. The default lifecycle unmounts after the closing transition. The panel exposes --collapsible-panel-height, --collapsible-panel-width, and transition attributes including data-starting-style and data-ending-style.

Closed SSR output follows the selected lifecycle and hydrates without changing the public relationship. Tinyrack CSS uses design-system motion tokens and removes decorative transitions under reduced motion. TRCollapsibleRoot, TRCollapsibleTrigger, TRCollapsiblePanel, their prop types, and their Base UI state types are exported from @tinyrack/ui/components/collapsible; CSS remains opt-in.