Accordion
neobrutal-ui/accordionFreeComponent
neobrutal-ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by neobrutal-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/accordion.jsonSource
1"use client";23import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";4import { DirectionProvider, useDirection } from "@base-ui/react/direction-provider";5import { mergeProps } from "@base-ui/react/merge-props";6import * as React from "react";78import { cn } from "@/lib/utils";9import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";1011type AccordionBaseProps = Omit<12 AccordionPrimitive.Root.Props<string>,13 "defaultValue" | "loopFocus" | "multiple" | "onValueChange" | "value"14> & {15 asChild?: boolean;16 children?: React.ReactNode;17 loop?: boolean;18 loopFocus?: boolean;19};2021type AccordionSingleProps = AccordionBaseProps & {22 collapsible?: boolean;23 defaultValue?: string;24 onValueChange?: (value: string, eventDetails: AccordionPrimitive.Root.ChangeEventDetails) => void;25 type: "single";26 value?: string;27};2829type AccordionMultipleProps = AccordionBaseProps & {30 collapsible?: never;31 defaultValue?: string[];32 onValueChange?: (33 value: string[],34 eventDetails: AccordionPrimitive.Root.ChangeEventDetails,35 ) => void;36 type: "multiple";37 value?: string[];38};3940type AccordionProps = AccordionSingleProps | AccordionMultipleProps;41type AccordionKeyDownHandler = NonNullable<AccordionPrimitive.Root.Props<string>["onKeyDown"]>;42type RenderProps = React.HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLElement> };43type AccordionContentStyle = React.CSSProperties & {44 "--radix-accordion-content-height"?: string;45 "--radix-accordion-content-width"?: string;46};4748const accordionContentCssVariables: AccordionContentStyle = {49 "--radix-accordion-content-height": "var(--accordion-panel-height)",50 "--radix-accordion-content-width": "var(--accordion-panel-width)",51};5253function mergeContentStyle(54 style: AccordionPrimitive.Panel.Props["style"],55): AccordionPrimitive.Panel.Props["style"] {56 if (typeof style === "function") {57 return (state) => ({ ...accordionContentCssVariables, ...style(state) });58 }5960 return { ...accordionContentCssVariables, ...style };61}6263function mergeRefs(...refs: (React.Ref<HTMLElement> | undefined)[]) {64 return (element: HTMLElement | null) => {65 refs.forEach((ref) => {66 if (typeof ref === "function") {67 ref(element);68 } else if (ref) {69 ref.current = element;70 }71 });72 };73}7475function preserveRadixEventCancellation(76 child: React.ReactElement<{ [key: string]: unknown; children?: React.ReactNode }>,77) {78 const eventProps: Record<string, unknown> = {};7980// … truncated
What it pulls in
npm packages
Files it writes
More from neobrutal-ui
All 100 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alertalert | neobrutal-ui | Components | Free | no deps | |
| Alert dialogalert-dialog | neobrutal-ui | Components | Free | 1 dep | |
| Avataravatar | neobrutal-ui | Components | Free | 1 dep | |
| Badgebadge | neobrutal-ui | Components | Free | no deps | |
| Breadcrumbbreadcrumb | neobrutal-ui | Components | Free | 1 dep | |
| Buttonbutton | neobrutal-ui | Components | Free | 1 dep | |
| Calendarcalendar | neobrutal-ui | Components | Free | 1 dep | |
| Cardcard | neobrutal-ui | Components | Free | no deps |
