Search

Search documentation

Collapsible

An interactive component which expands/collapses a panel.

Installation

pnpm dlx shadcn@latest add @evolphin/collapsible

Usage

import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} from "@/components/ui/collapsible";
<Collapsible>
  <CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger>
  <CollapsibleContent>
    Yes. Free to use for personal and commercial projects. No attribution
    required.
  </CollapsibleContent>
</Collapsible>

Type Definitions

interface CollapsibleProps {
  /** The controlled open state of the collapsible */
  open?: boolean;
CollapsibleProps.open?: boolean | undefined

The controlled open state of the collapsible

/** The default open state when uncontrolled */ ?: boolean; /** Event handler called when the open state changes */ ?: (: boolean) => void; /** Whether the collapsible is disabled */ ?: boolean; }

Examples

Default

@peduarte starred 3 repositories

@radix-ui/primitives

API Reference

Collapsible

PropTypeDefaultDescription
openboolean-The controlled open state of the collapsible.
defaultOpenboolean-The default open state when uncontrolled.
onOpenChange(open: boolean) => void-Event handler called when the open state changes.
disabledbooleanfalseWhether the collapsible is disabled.

CollapsibleTrigger

PropTypeDefaultDescription
asChildbooleanfalseChange the component to the HTML tag or custom component of the only child.

CollapsibleContent

PropTypeDefaultDescription
forceMountboolean-Used to force mounting when more control is needed.

On this page