Docs
Collapsible
Collapsible
An interactive component which expands/collapses a panel.
This component uses Radix UI
@peduarte starred 3 repositories
@radix-ui/primitives
'use client'
import * as React from 'react'
import { ChevronsUpDown, Plus, X } from 'lucide-react'
import { Button } from 'ui'
import { Collapsible_Shadcn_, CollapsibleContent_Shadcn_, CollapsibleTrigger_Shadcn_ } from 'ui'
export function CollapsibleDemo() {
const [isOpen, setIsOpen] = React.useState(false)
return (
<Collapsible_Shadcn_ open={isOpen} onOpenChange={setIsOpen} className="w-[350px] space-y-2">
<div className="flex items-center justify-between space-x-4 px-4">
<h4 className="text-sm font-semibold">@peduarte starred 3 repositories</h4>
<CollapsibleTrigger_Shadcn_ asChild>
<Button type="outline" size="medium" className="w-9 p-0">
<ChevronsUpDown className="h-4 w-4" />
<span className="sr-only">Toggle</span>
</Button>
</CollapsibleTrigger_Shadcn_>
</div>
<div className="rounded-md border px-4 py-3 font-mono text-sm">@radix-ui/primitives</div>
<CollapsibleContent_Shadcn_ className="space-y-2">
<div className="rounded-md border px-4 py-3 font-mono text-sm">@radix-ui/colors</div>
<div className="rounded-md border px-4 py-3 font-mono text-sm">@stitches/react</div>
</CollapsibleContent_Shadcn_>
</Collapsible_Shadcn_>
)
}
Installation
npx shadcn-ui@latest add 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>