Navigation
Accordion
Disclosure rows with a +/× toggle; the open item becomes a raised white card.
react-aria-componentslucide-react
Preview
"use client";
import { CreditCard, ShieldCheck, Sparkles } from "lucide-react";
import { Accordion, AccordionItem } from "@/components/ui/accordion";
export default function Example() {
return (
<Accordion defaultExpandedKeys={["credits"]} className="w-full max-w-lg">
<AccordionItem id="credits" icon={<Sparkles />} title="How are AI credits counted?">
One credit per AI search and one per enriched contact. Re-running a saved search only counts new matches.
</AccordionItem>
<AccordionItem id="billing" icon={<CreditCard />} title="Can I change plans mid-cycle?">
Yes. Upgrades apply immediately and are prorated; downgrades take effect at the next renewal.
</AccordionItem>
<AccordionItem id="security" icon={<ShieldCheck />} title="Where is my data stored?">
In SOC 2 Type II certified data centers in the US or EU, depending on your workspace region.
</AccordionItem>
</Accordion>
);
}Installation
Components are copied into your project — no runtime package.
Install the following dependencies:
terminalnpm install react-aria-components lucide-reactCreate a
accordion.tsxfile and paste the following code into it.src/components/ui/accordion.tsx"use client"; import { Plus } from "lucide-react"; import type { ReactNode } from "react"; import { Button as AriaButton, Disclosure, DisclosureGroup, type DisclosureGroupProps, DisclosurePanel, Heading, } from "react-aria-components"; import { cx } from "@/utils/cx"; export function Accordion({ className, ...props }: Omit<DisclosureGroupProps, "className"> & { className?: string }) { return <DisclosureGroup {...props} className={cx("flex flex-col gap-2", className)} />; } export interface AccordionItemProps { id: string; title: ReactNode; icon?: ReactNode; children: ReactNode; className?: string; } /** Row with a +/× toggle. The open item becomes a white raised card. */ export function AccordionItem({ id, title, icon, children, className }: AccordionItemProps) { return ( <Disclosure id={id} className={cx( "group rounded-md bg-subtle ring-1 ring-inset ring-line transition-[background,box-shadow]", "hover:bg-muted data-expanded:bg-surface data-expanded:shadow-card data-expanded:hover:bg-surface", className, )} > <Heading> <AriaButton slot="trigger" className="flex w-full cursor-default items-center gap-3 rounded-md px-4 py-3.5 text-left text-base font-medium text-fg outline-none data-focus-visible:shadow-focus [&_svg]:size-4" > {icon && <span className="text-fg-secondary">{icon}</span>} <span className="flex-1">{title}</span> <Plus aria-hidden className="text-fg-muted transition-transform duration-200 group-data-expanded:rotate-45" /> </AriaButton> </Heading> {/* Padding only while open: a closed panel stays in the DOM (hidden="until-found", so find-in-page works) and would otherwise keep its bottom padding. */} <DisclosurePanel className="px-4 text-base text-fg-secondary group-data-expanded:-mt-1 group-data-expanded:pb-4">{children}</DisclosurePanel> </Disclosure> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.