For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
119

Collapsible

An interactive component which expands/collapses a panel.

Order #4189

StatusShipped
"use client";

import { ChevronsUpDown } from "lucide-react";
import * as React from "react";

import { Button } from "@/components/ui/button";

Installation

$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.com/r/collapsible.json

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>

Composition

Use the following composition to build a Collapsible:

Collapsible
├── CollapsibleTrigger
└── CollapsibleContent

Controlled State

Use the open and onOpenChange props to control the state.

import * as React from "react";
 
export function Example() {
  const [open, setOpen] = React.useState(false);
 
  return (
    <Collapsible open={open} onOpenChange={setOpen}>
      <CollapsibleTrigger>Toggle</CollapsibleTrigger>
      <CollapsibleContent>Content</CollapsibleContent>
    </Collapsible>
  );
}

Basic

import { ChevronDownIcon } from "lucide-react";

import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import {
  Collapsible,

Settings Panel

Use a trigger button to reveal additional settings.

Radius
Set the corner radius of the element.
"use client";

import { MaximizeIcon, MinimizeIcon } from "lucide-react";
import * as React from "react";

import { Button } from "@/components/ui/button";

File Tree

Use nested collapsibles to build a file tree.

import { ChevronRightIcon, FileIcon, FolderIcon } from "lucide-react";

import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import {
  Collapsible,

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

الطلب #4189

الحالةتم الشحن
"use client";

import { ChevronsUpDown } from "lucide-react";
import * as React from "react";

import { useTranslation } from "@/components/language-selector";

API Reference

See the Base UI documentation for more information.