diff --git a/packages/ui/package.json b/packages/ui/package.json index ee48456..1c5f2f1 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -5,6 +5,7 @@ "type": "module", "main": "./src/index.ts", "dependencies": { + "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-slot": "^1.1.0", diff --git a/packages/ui/src/accordion.tsx b/packages/ui/src/accordion.tsx new file mode 100644 index 0000000..1fd53c3 --- /dev/null +++ b/packages/ui/src/accordion.tsx @@ -0,0 +1,52 @@ +import * as AccordionPrimitive from '@radix-ui/react-accordion' +import { ChevronDown } from 'lucide-react' +import * as React from 'react' + +import { cn } from './lib/cn' + +const Accordion = AccordionPrimitive.Root + +const AccordionItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AccordionItem.displayName = 'AccordionItem' + +const AccordionTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + svg]:rotate-180', + className, + )} + {...props} + > + {children} + + + +)) +AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName + +const AccordionContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + +
{children}
+
+)) + +AccordionContent.displayName = AccordionPrimitive.Content.displayName + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index 8ea7742..f6217e3 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -7,3 +7,4 @@ export * from './badge' export * from './card' export * from './input' export * from './sheet' +export * from './accordion'