codefast/ui

Command Palette

Search for a command to run...

Layout

Accordion

Expandable sections with smooth animation. Supports single or multiple open items.

Install

pnpm add @codefast/ui

Import path

@codefast/ui/accordion

Examples

Demo

A vertically stacked set of interactive headings that each reveal a section of content.

Basic

A basic accordion that shows one item at a time. The first item is open by default.

Click on 'Forgot Password' on the login page, enter your email address, and we'll send you a link to reset your password. The link will expire in 24 hours.

Multiple

Use type=multiple to allow multiple items to be open at the same time.

Manage how you receive notifications. You can enable email alerts for updates or push notifications for mobile devices.

Disabled

Use the disabled prop on AccordionItem to disable individual items.

Borders

Add borders to the Accordion and items for a more defined separation.

We offer monthly and annual subscription plans. Billing is charged at the beginning of each cycle, and you can cancel anytime. All plans include automatic backups, 24/7 support, and unlimited team members.

Card

Wrap the Accordion in a Card component.

Subscription & Billing
Common questions about your account, plans, payments and cancellations.

We offer three subscription tiers: Starter ($9/month), Professional ($29/month), and Enterprise ($99/month). Each plan includes increasing storage limits, API access, priority support, and team collaboration features.

RTL

Right-to-left layout support for languages such as Arabic and Hebrew.

Translations are AI-generated for demonstration and may be imperfect.

انقر على 'نسيت كلمة المرور' في صفحة تسجيل الدخول، أدخل عنوان بريدك الإلكتروني، وسنرسل لك رابطًا لإعادة تعيين كلمة المرور. سينتهي صلاحية الرابط خلال 24 ساعة.

Anatomy

How the parts compose. Copy this skeleton and fill in the slots.

import {
  Accordion, AccordionItem, AccordionTrigger, AccordionContent,
} from "@codefast/ui/accordion";

<Accordion type="single" collapsible>
  <AccordionItem value="a">
    <AccordionTrigger>…</AccordionTrigger>
    <AccordionContent>…</AccordionContent>
  </AccordionItem>
</Accordion>

API reference

Props for each part of the component. All native element props are also forwarded.

Accordion

PropTypeDefaultDescription
type"single" | "multiple"Whether one or many items can be open.
collapsiblebooleanfalseFor type=single, allow closing the open item. Ignored for multiple.
value / defaultValuestring | string[]Controlled / uncontrolled open item(s).

Accessibility

Built to be keyboard-navigable and screen-reader friendly out of the box.

KeyFunction
TabMoves focus to the next trigger.
EnterToggles the focused panel.
SpaceToggles the focused panel.
Arrow+DownMoves focus to the next trigger.
Arrow+UpMoves focus to the previous trigger.
  • Each trigger is a button with aria-expanded and aria-controls set automatically.
  • Panels are linked back to their trigger via aria-labelledby.

Guidelines

Conventions that keep usage consistent across an app.

Do

  • Use for FAQs and progressively-disclosed settings.
  • Keep trigger labels scannable and self-explanatory.

Don’t

  • Don’t hide content the user needs to see at a glance.
  • Don’t nest accordions deeply — it gets hard to track state.