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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import Collapsible, CollapsibleTrigger and CollapsibleContent from @/components/kamod-ui/collapsible. Motion is optional — core CollapsibleContent includes CSS height animation.
pnpm add @kamod-ch/uiCopy 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 { 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.
// 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthControlled 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthBasic
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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthSettings 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthFile 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps 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.
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
? 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.Collapsible
CollapsibleProps
| Prop / type | Description |
|---|---|
children | Configure
|
defaultOpen | Uncontrolled initial state
|
onOpenChange | Called when open state changes (toggle or programmatic)
|
open | Controlled open state
|
CollapsibleContent
CollapsibleContentProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
duration | Grid transition duration, e.g. `400ms`
|
forceMount | Configure
|
largeContentThreshold | Use max-height animation for very tall content to reduce micro-jank.
|
style | Configure
|
timingFunction | CSS timing function, e.g. `cubic-bezier(0.4, 0, 0.2, 1)`
|
CollapsibleTrigger
CollapsibleTriggerProps
| Prop / type | Description |
|---|---|
asChild | Configure
|
children | Configure
|
data-slot | Configure
|
onClick | Configure
|
ref | Configure
|
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 fieldsCollapsibleContextValueCollapsible.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CollapsibleContextValue before adapting it.open, setOpenCollapsible Props
4 declared fieldsCollapsiblePropsCollapsible.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 fieldsCollapsibleContentPropsCollapsibleContent.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 fieldsCollapsibleTriggerPropsCollapsibleTrigger.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.
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.