Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Navigation & Disclosure

Collapsible

Progressive disclosure with open/onOpenChange, asChild triggers, height animation (accordion-style), shadcn-aligned examples. Organize content into understandable destinations and reveal detail when it becomes relevant. Keep the active location or expanded state easy to recognize. Import it from @/components/kamod-ui/collapsible.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import Collapsible, CollapsibleTrigger and CollapsibleContent from @/components/kamod-ui/collapsible. Motion is optional — core CollapsibleContent includes CSS height animation.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Wrap trigger and content. Use open and onOpenChange for controlled state. Use CollapsibleTrigger asChild with Button for icon toggles. CollapsibleContent animates height (respects prefers-reduced-motion).

Import SetupTypeScript
import { Collapsible } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Collapsible in Different Contexts, from the starting pattern to the compositions below. Begin with Demo, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Demo

Reveal Supporting Detail on Demand. Control a Collapsible within an order card to reveal supporting details only when needed. A ghost icon trigger keeps the summary compact, while the expanded area provides context without replacing the main order information.

The order-card composition suits optional detail rather than required instructions; important next steps should remain visible without asking users to discover the disclosure.

src/components/CollapsibleExample.tsx1 line
// See previewCode hero — open + onOpenChange, asChild Button, ChevronsUpDown.

Usage

Separate the Trigger from the Revealed Content. Pair CollapsibleTrigger with CollapsibleContent for a minimal disclosure. The trigger changes visibility and the content contains the optional explanation, giving you a small foundation before adding card surfaces or custom controls.

Preserve the trigger's keyboard behavior and expanded state, and avoid hiding the only explanation of its purpose inside the closed content.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Controlled State

Coordinate Visibility with Application State. Supply open and onOpenChange when the disclosure must coordinate with external controls or application state. The parent owns the boolean value, and the collapsible reports requests to change it through the callback.

Keep onOpenChange connected to that source of truth and consider where focus should remain when another part of the page opens or closes the panel.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Basic

Make the Whole Summary Easy to Activate. Use a full-width ghost trigger inside a card so the summary row clearly opens the details below. A rotating chevron reinforces the expanded state without making the icon the only indicator of the interaction.

Keep nested links or buttons outside that trigger to avoid conflicting interactive targets, and ensure the label still describes the content when the icon is not visible.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Settings Panel

Keep Advanced Settings Optional and Understandable. Keep common settings visible and reveal less frequently used fields inside CollapsibleContent. The maximize/minimize control explains that the same settings area can show more detail while preserving the surrounding form context.

Decide whether hidden fields retain their values, explain any dependencies outside the disclosure, and ensure validation does not strand an error inside an unnoticed closed panel.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

File Tree

Keep Folder Disclosure Distinct from File Actions. Nest collapsibles to represent folder branches, with a separate trigger for each expandable level. The tree example combines these disclosures with a tabbed header, illustrating how local expansion can coexist with another navigation choice.

Use stable keys and test deep nesting; choose Tree when you need dedicated tree selection and keyboard navigation.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Collapsible using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/collapsible16.5 KB min · 4.1 KB gzipSignals: direct@preact/signals

Collapsible

CollapsibleProps

Collapsible documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildCollapsibleProps

Configure children for Collapsible. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultOpen
booleanCollapsibleProps

Uncontrolled initial state

Default
false
onOpenChange
((open: boolean) => void)CollapsibleProps

Called when open state changes (toggle or programmatic)

Default
—
open
booleanCollapsibleProps

Controlled open state

Default
—

CollapsibleContent

CollapsibleContentProps

CollapsibleContent documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildCollapsibleContentProps

Configure children for CollapsibleContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>CollapsibleContentProps

Configure class for CollapsibleContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
duration
stringCollapsibleContentProps

Grid transition duration, e.g. `400ms`

Default
"320ms"
forceMount
booleanCollapsibleContentProps

Configure forceMount for CollapsibleContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
largeContentThreshold
numberCollapsibleContentProps

Use max-height animation for very tall content to reduce micro-jank.

Default
560
style
string | CSSProperties | SignalLike<string | CSSProperties | undefined>CollapsibleContentProps

Configure style for CollapsibleContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
timingFunction
stringCollapsibleContentProps

CSS timing function, e.g. `cubic-bezier(0.4, 0, 0.2, 1)`

Default
"cubic-bezier(0.22, 1, 0.36, 1)"

CollapsibleTrigger

CollapsibleTriggerProps

CollapsibleTrigger documented props
Prop / typeDescription
asChild
booleanCollapsibleTriggerProps

Configure asChild for CollapsibleTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
children
ComponentChild[] | ComponentChildCollapsibleTriggerProps

Configure children for CollapsibleTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringCollapsibleTriggerProps

Configure data-slot for CollapsibleTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onClick
MouseEventHandler<HTMLButtonElement>CollapsibleTriggerProps

Configure onClick for CollapsibleTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
ref
Ref<HTMLButtonElement>CollapsibleTriggerProps

Configure ref for CollapsibleTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

CollapsibleContextValue

2 declared fields
CollapsibleContextValue
Exported Source Declaration from Collapsible.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CollapsibleContextValue before adapting it.
Required fields
open, setOpen

Collapsible Props

4 declared fields
CollapsibleProps
Exported Source Declaration from Collapsible.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CollapsibleProps before adapting it.

CollapsibleContent Props

5 declared fields
CollapsibleContentProps
Exported Source Declaration from CollapsibleContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CollapsibleContentProps before adapting it.

CollapsibleTrigger Props

3 declared fields
CollapsibleTriggerProps
Exported Source Declaration from CollapsibleTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CollapsibleTriggerProps before adapting it.

Accessibility

CollapsibleTrigger communicates aria-expanded, while closed content uses hidden/inert handling. It is a disclosure pattern, not a dialog: opening content does not imply a modal focus trap or a new window.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.