Aurora Accordion
aurora-dinglebear-ai/aurora-accordionFreeComponent
Tokenized disclosure list for compact details, command output, and configuration sections.
Install it
npx shadcn@latest add https://aurora.dinglebear.ai/r/aurora-accordion.jsonSource
1"use client"23import * as React from "react"4import * as AccordionPrimitive from "@radix-ui/react-accordion"5import { ChevronDown } from "lucide-react"6import { cn } from "@/lib/utils"78export interface AuroraAccordionProps9 extends Omit<10 React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Root>,11 "children" | "collapsible" | "defaultValue" | "onValueChange" | "type" | "value"12 > {13 children: React.ReactNode14 type?: "single" | "multiple"15 collapsible?: boolean16 defaultValue?: string | string[]17 value?: string | string[]18 onValueChange?: ((value: string) => void) | ((value: string[]) => void)19 ref?: React.Ref<React.ComponentRef<typeof AccordionPrimitive.Root>>20}2122export interface AuroraAccordionItemProps23 extends Omit<24 React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>,25 "children" | "title" | "value"26 > {27 title: React.ReactNode28 meta?: React.ReactNode29 defaultOpen?: boolean30 value?: string31 children: React.ReactNode32 ref?: React.Ref<React.ComponentRef<typeof AccordionPrimitive.Item>>33}3435export type AccordionProps = AuroraAccordionProps36export type AccordionItemProps = AuroraAccordionItemProps3738function Accordion({39 ref,40 children,41 className,42 type = "multiple",43 collapsible = true,44 defaultValue,45 value,46 onValueChange,47 style,48 ...props49}: AuroraAccordionProps) {50 const items = React.Children.toArray(children)5152 const normalizedChildren = items.map((child, index) => {53 if (!React.isValidElement<AuroraAccordionItemProps>(child)) {54 return child55 }5657 return React.cloneElement(child, {58 value: child.props.value ?? `accordion-item-${index}`,59 })60 })6162 const derivedDefaultValue = React.useMemo(() => {63 if (defaultValue !== undefined) {64 return defaultValue65 }6667 const openValues = items.flatMap((child, index) => {68 if (!React.isValidElement<AuroraAccordionItemProps>(child) || !child.props.defaultOpen) {69 return []70 }7172 return [child.props.value ?? `accordion-item-${index}`]73 })7475 return type === "multiple" ? openValues : openValues[0]76 }, [defaultValue, items, type])7778 const rootClassName = cn("overflow-hidden rounded-[12px] border", className)79 const rootStyle = {80 background: "var(--aurora-panel-medium)",81 borderColor: "var(--aurora-border-default)",82 ...style,83 }8485 if (type === "multiple") {86 return (87 <AccordionPrimitive.Root88 ref={ref}89 data-slot="accordion"90 type="multiple"91// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from aurora
All 176 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aurora Alert Dialogaurora-alert-dialog | aurora | Components | Free | 2 deps | |
| Aurora Aspect Ratioaurora-aspect-ratio | aurora | Components | Free | no deps | |
| Aurora Avataraurora-avatar | aurora | Components | Free | 1 dep | |
| Aurora Badgeaurora-badge | aurora | Components | Free | 2 deps | |
| Aurora Banneraurora-banner | aurora | Components | Free | 1 dep | |
| Aurora Breadcrumbaurora-breadcrumb | aurora | Components | Free | 2 deps | |
| Aurora Buttonaurora-button | aurora | Components | Free | 2 deps | |
| Aurora Button Groupaurora-button-group | aurora | Components | Free | no deps |
