mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 22:18:39 +00:00
48 lines
1.1 KiB
Plaintext
48 lines
1.1 KiB
Plaintext
---
|
|
title: Collapsible
|
|
description: An interactive component which expands/collapses a panel.
|
|
component: true
|
|
featured: true
|
|
radix:
|
|
link: https://www.radix-ui.com/docs/primitives/components/collapsible
|
|
api: https://www.radix-ui.com/docs/primitives/components/collapsible#api-reference
|
|
---
|
|
|
|
<ComponentExample src="/components/examples/collapsible/demo.tsx">
|
|
<CollapsibleDemo />
|
|
</ComponentExample>
|
|
|
|
## Installation
|
|
|
|
1. Install the `@radix-ui/react-collapsible` component from radix-ui:
|
|
|
|
```bash
|
|
npm install @radix-ui/react-collapsible
|
|
```
|
|
|
|
2. Copy and paste the following code into your project.
|
|
|
|
<ComponentSource src="/components/ui/collapsible.tsx" />
|
|
|
|
<Callout>
|
|
|
|
This is the `<Collapsible />` primitive. You can place it in a file at `components/ui/collapsible.tsx`.
|
|
|
|
</Callout>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { Collapsible } from "@/components/ui/collapsible"
|
|
```
|
|
|
|
```tsx
|
|
<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>
|
|
```
|