Animated Accordion for React
An animated React accordion whose sections open on a spring, with every trigger a real button in the tab order. Use it as a React accordion for an FAQ section on a pricing or landing page, where the default glass variant puts all questions in one card and the open item rises as a lighter pane.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/accordion.jsonAccordionAccordionItemAccordionPanelAccordionTrigger- +2 more
FAQ
The default glass variant: one card, and the open item rises as a lighter pane. Leading icons pick up the accent while open.
import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@/components/sheenui/accordion/accordion";
// Package build (after the first npm release, or a packed tarball): import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@sheenui/theme";
import { MessageCircle as MessageIcon, Shield as ShieldIcon, Truck as TruckIcon, Undo2 as UndoIcon } from "lucide-react";
const faqs = [
{
value: "shipping",
icon: <TruckIcon />,
title: "How long does shipping take?",
description: "Orders and delivery",
body: "Orders placed before 2 pm ship the same day. Standard delivery takes three to five business days; express arrives the next business day in most cities.",
},
{
value: "returns",
icon: <UndoIcon />,
title: "Can I return an item?",
description: "Free within 30 days",
body: "Yes. Start a return from your order page within 30 days and drop the parcel at any pickup point. Refunds land on your original payment method within five days.",
},
{
value: "warranty",
icon: <ShieldIcon />,
title: "What does the warranty cover?",
description: "Two years, parts and labour",
body: "Every device carries a two-year warranty against manufacturing defects. Accidental damage is covered only with SheenCare.",
},
{
value: "support",
icon: <MessageIcon />,
title: "How do I reach support?",
description: "Chat, email or phone",
body: "Chat with us from any page, or email help@sheen.example. Phone support runs 8 am to 8 pm on weekdays.",
},
];
export function Example() {
return (
<Accordion defaultValue={["shipping"]}>
{faqs.map((faq) => (
<AccordionItem key={faq.value} value={faq.value}>
<AccordionTrigger icon={faq.icon} description={faq.description}>
{faq.title}
</AccordionTrigger>
<AccordionPanel>{faq.body}</AccordionPanel>
</AccordionItem>
))}
</Accordion>
);
}Files to copy
3 folders · 2 files · 4 packages
- From
theme/src/ components/accordion/lib/{cn.ts, heading.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/accordion.jsonRegistry item: accordion. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/button/components/glass-card/components/spinner/hooks/{use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}motion/{gate.ts, light-follower.ts, tokens.ts}lib/{form.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/glass-card.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Separated, several open
Each item is its own glass card. multiple lets any number stay open; the plus folds into a minus.
import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@/components/sheenui/accordion/accordion";
// Package build (after the first npm release, or a packed tarball): import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@sheenui/theme";
export function Example() {
return (
<Accordion variant="separated" multiple defaultValue={["plans", "billing"]}>
<AccordionItem value="plans">
<AccordionTrigger indicator="plus">Can I switch plans later?</AccordionTrigger>
<AccordionPanel>Any time. Upgrades apply at once…</AccordionPanel>
</AccordionItem>
<AccordionItem value="billing">
<AccordionTrigger indicator="plus">When am I billed?</AccordionTrigger>
<AccordionPanel>On the same day each month…</AccordionPanel>
</AccordionItem>
<AccordionItem value="team">
<AccordionTrigger indicator="plus">Do you offer team discounts?</AccordionTrigger>
<AccordionPanel>Teams of ten or more get 20% off…</AccordionPanel>
</AccordionItem>
</Accordion>
);
}Plain, controlled, inside a card
variant="plain" has no surface of its own, for settings inside an existing card. value / onValueChange control which sections are open; a disabled item stays visible.
Open: profile
import { useState } from "react";
import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@/components/sheenui/accordion/accordion";
import { Button } from "@/components/sheenui/button/button";
import { GlassCard } from "@/components/sheenui/glass-card/glass-card";
// Package build (after the first npm release, or a packed tarball): import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Button, GlassCard } from "@sheenui/theme";
import { CreditCard as CardIcon, User as UserIcon } from "lucide-react";
// This example also uses button, glass-card: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/glass-card.json
export function Example() {
const [open, setOpen] = useState<string[]>(["profile"]);
// Every item that can open: the disabled one stays closed.
const all = ["profile", "notifications", "security"];
return (
<>
<Button size="sm" variant="glass" onClick={() => setOpen(all)}>Expand all</Button>
<Button size="sm" variant="ghost" onClick={() => setOpen([])}>Collapse all</Button>
<GlassCard className="p-2">
<Accordion variant="plain" multiple value={open} onValueChange={(value) => setOpen(value as string[])}>
<AccordionItem value="profile">
<AccordionTrigger icon={<UserIcon />}>Profile</AccordionTrigger>
<AccordionPanel>Name, photo and email.</AccordionPanel>
</AccordionItem>
<AccordionItem value="notifications">
<AccordionTrigger>Notifications</AccordionTrigger>
<AccordionPanel>Choose what we email you about.</AccordionPanel>
</AccordionItem>
<AccordionItem value="security">
<AccordionTrigger>Security</AccordionTrigger>
<AccordionPanel>Password and two-step sign-in.</AccordionPanel>
</AccordionItem>
<AccordionItem value="billing" disabled>
<AccordionTrigger icon={<CardIcon />} description="Ask an owner to unlock">Billing</AccordionTrigger>
<AccordionPanel>Plans and invoices.</AccordionPanel>
</AccordionItem>
</Accordion>
</GlassCard>
</>
);
}Accordion
AccordionItem
AccordionTrigger
AccordionPanel
Keyboard
Accessibility
- Each trigger is a native button inside a heading (headingLevel sets the level) with aria-expanded and aria-controls.
- Closed panels are hidden from the accessibility tree, so their links are not tabbable; hiddenUntilFound lets find-in-page open matching panels.
- A disabled item is announced as dimmed; the chevron and icon tile are aria-hidden.
When to use Accordion
- Use it for an FAQ below a pricing table, or a settings screen with long sections, where only the answer you open takes space and every trigger stays a real button in the tab order.
- Use the separated variant with multiple for a settings or filter panel, where each group is its own glass card and several can stay open while someone compares them.
- Use the plain variant inside an existing card, such as a checkout summary or a sidebar, when the accordion should not add a surface of its own.
- Skip it when a section is independent and should not close its neighbors; Collapsible is a single show and hide region, and Tabs is better when users compare parallel views.
- Pair it with Badge in a trigger description, Field and Input for settings groups inside panels, and the Kbd component to show shortcuts in help content.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .