Collapse
indiacn/collapseFreeComponent
Single collapsible region powered by Radix Collapsible.
Install it
npx shadcn@latest add https://indiacn.in/r/collapse.jsonSource
1'use client';23import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';4import { ComponentProps } from 'react';56import { cn } from '@/lib/utils';78/** Collapsible root component. */9function Collapse(props: ComponentProps<typeof CollapsiblePrimitive.Root>) {10 return <CollapsiblePrimitive.Root {...props} />;11}1213/** Collapsible trigger button. */14function CollapseTrigger(props: ComponentProps<typeof CollapsiblePrimitive.Trigger>) {15 return <CollapsiblePrimitive.Trigger {...props} />;16}1718/**19 * Collapsible content panel.20 * Uses radix-collapsible-content-height (not the accordion height var) so the21 * animated height matches the actual content; mismatched vars caused the22 * trigger to jump on toggle.23 */24function CollapseContent({25 className,26 ...props27}: ComponentProps<typeof CollapsiblePrimitive.Content>) {28 return (29 <CollapsiblePrimitive.Content30 className={cn(31 'data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down overflow-hidden',32 className,33 )}34 {...props}35 />36 );37}3839export { Collapse, CollapseTrigger, CollapseContent };
What it pulls in
npm packages
Other registry items
Files it writes
More from indiacn
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | indiacn | Components | Free | 2 deps | |
| Alertalert | indiacn | Components | Free | 2 deps | |
| Badgebadge | indiacn | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | indiacn | Components | Free | 1 dep | |
| Buttonbutton | indiacn | Components | Free | 3 deps | |
| Button Groupbutton-group | indiacn | Components | Free | no deps | |
| Cardcard | indiacn | Components | Free | 1 dep | |
| Chipchip | indiacn | Components | Free | 2 deps |
