Unified UI

Accordion

A collapsible accordion component with single and multiple expand modes, built on Radix UI.

Basic

Collapsible content sections for organizing information. Supports single and multiple expand modes with animated transitions.

Unified UI is a token-driven, accessible React design system built with Tailwind CSS v4 and Framer Motion.

Installation

Install the component via the CLI in one command.

npx @work-rjkashyap/unified-ui add accordion
pnpm dlx @work-rjkashyap/unified-ui add accordion
npx @work-rjkashyap/unified-ui add accordion
bunx @work-rjkashyap/unified-ui add accordion

If you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.

Or install the full package

Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.

npm install @work-rjkashyap/unified-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import {
	Accordion,
	AccordionItem,
	AccordionTrigger,
	AccordionContent,
} from "@work-rjkashyap/unified-ui";

Single Expand Mode

Only one item can be open at a time. Set collapsible to allow closing all items.

Multiple Expand Mode

Multiple items can be open simultaneously.

Content for section 1.

Content for section 3.

Variants

Bordered (default)

The default variant renders items with borders between them.

Borderless

A cleaner look without dividing borders. Useful inside cards or already-bordered containers.

Sizes

Two sizes are available for different content density needs.

Small

Medium (default)

Disabled Items

Individual accordion items can be disabled.

Controlled

Control the expanded state externally with value and onValueChange.

// Single mode
const [value, setValue] = useState("item-1");

<Accordion type="single" collapsible value={value} onValueChange={setValue}>
	<AccordionItem value="item-1">
		<AccordionTrigger>Section 1</AccordionTrigger>
		<AccordionContent>Content 1</AccordionContent>
	</AccordionItem>
	<AccordionItem value="item-2">
		<AccordionTrigger>Section 2</AccordionTrigger>
		<AccordionContent>Content 2</AccordionContent>
	</AccordionItem>
</Accordion>;

// Multiple mode
const [values, setValues] = useState(["item-1"]);

<Accordion type="multiple" value={values} onValueChange={setValues}>
	<AccordionItem value="item-1">
		<AccordionTrigger>Section 1</AccordionTrigger>
		<AccordionContent>Content 1</AccordionContent>
	</AccordionItem>
	<AccordionItem value="item-2">
		<AccordionTrigger>Section 2</AccordionTrigger>
		<AccordionContent>Content 2</AccordionContent>
	</AccordionItem>
</Accordion>;

FAQ Pattern

A common pattern for FAQ sections.

Props

Accordion

PropTypeDefaultDescription
type"single" | "multiple"requiredWhether one or multiple items can be open.
collapsiblebooleanfalseAllow closing all items (single mode only).
valuestring | string[]Controlled expanded value(s).
defaultValuestring | string[]Default expanded value(s) (uncontrolled).
onValueChange(value: string | string[]) => voidCallback when expanded state changes.
variant"bordered" | "borderless""bordered"Visual variant.
size"sm" | "md""md"Size of the accordion items.
classNamestringAdditional CSS classes.

AccordionItem

PropTypeDefaultDescription
valuestringrequiredUnique identifier for this item.
disabledbooleanfalseWhether this item is disabled.
classNamestringAdditional CSS classes.

AccordionTrigger

PropTypeDefaultDescription
classNamestringAdditional CSS classes.
childrenReactNodeTrigger label content.

AccordionContent

PropTypeDefaultDescription
classNamestringAdditional CSS classes.
childrenReactNodeCollapsible content.

Accessibility

Built on @radix-ui/react-accordion which provides full WAI-ARIA Accordion pattern compliance.

  • Keyboard navigationEnter / Space toggles an item. Arrow Up / Arrow Down moves focus between triggers. Home / End jumps to first/last trigger.
  • Focus ring — Visible on keyboard navigation via focus-visible.
  • ARIA attributesaria-expanded, aria-controls, and role attributes are managed automatically by Radix.
  • Disabled — Disabled items are excluded from keyboard navigation and marked with aria-disabled.
  • Animation — Content expand/collapse uses CSS grid animation. Respects prefers-reduced-motion.
  • Chevron indicator — Rotates 180° when the item is expanded, providing a visual cue for the current state.

Design Tokens

TokenUsage
--foregroundTrigger text color
--muted-foregroundTrigger hover and content text
--borderBordered variant dividers
--duration-normalChevron rotation and content animation
--easing-standardAnimation easing curve

On this page