accordion
shadcn-zhcndoc/accordionFreeComponent
shadcn-zhcndoc publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn-zhcndoc on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn.zhcndoc.com/r/styles/new-york/accordion.jsonSource
1"use client"23import * as React from "react"4import * as AccordionPrimitive from "@radix-ui/react-accordion"5import { ChevronDown } from "lucide-react"67import { cn } from "@/lib/utils"89const Accordion = AccordionPrimitive.Root1011const AccordionItem = React.forwardRef<12 React.ElementRef<typeof AccordionPrimitive.Item>,13 React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>14>(({ className, ...props }, ref) => (15 <AccordionPrimitive.Item16 ref={ref}17 className={cn("border-b", className)}18 {...props}19 />20))21AccordionItem.displayName = "AccordionItem"2223const AccordionTrigger = React.forwardRef<24 React.ElementRef<typeof AccordionPrimitive.Trigger>,25 React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>26>(({ className, children, ...props }, ref) => (27 <AccordionPrimitive.Header className="flex">28 <AccordionPrimitive.Trigger29 ref={ref}30 className={cn(31 "flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",32 className33 )}34 {...props}35 >36 {children}37 <ChevronDown className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />38 </AccordionPrimitive.Trigger>39 </AccordionPrimitive.Header>40))41AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName4243const AccordionContent = React.forwardRef<44 React.ElementRef<typeof AccordionPrimitive.Content>,45 React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>46>(({ className, children, ...props }, ref) => (47 <AccordionPrimitive.Content48 ref={ref}49 className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"50 {...props}51 >52 <div className={cn("pb-4 pt-0", className)}>{children}</div>53 </AccordionPrimitive.Content>54))55AccordionContent.displayName = AccordionPrimitive.Content.displayName5657export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
Files it writes
More from shadcn-zhcndoc
All 61 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| alertalert | shadcn-zhcndoc | Components | Free | no deps | |
| alert-dialogalert-dialog | shadcn-zhcndoc | Components | Free | no deps | |
| aspect-ratioaspect-ratio | shadcn-zhcndoc | Components | Free | no deps | |
| attachmentattachment | shadcn-zhcndoc | Components | Free | no deps | |
| avataravatar | shadcn-zhcndoc | Components | Free | no deps | |
| badgebadge | shadcn-zhcndoc | Components | Free | no deps | |
| breadcrumbbreadcrumb | shadcn-zhcndoc | Components | Free | no deps | |
| bubblebubble | shadcn-zhcndoc | Components | Free | no deps |
