Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Accordion

Content sections that can be expanded and collapsed.

View in Storybook (opens in a new tab)

Installation

import { Accordion } from "@ginga-ui/core";

Basic usage

The simplest accordion example.

We offer a full refund within 90 days of purchase, no questions asked. Just send us an email.

Follow our step-by-step guide to finish setup in under 5 minutes. No technical knowledge required.

Yes, we provide support 24/7 via email and live chat. We usually reply within 2 hours.
accordion.tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@ginga-ui/core";
import { ChevronDown } from "lucide-react";

export function BasicExample() {
  return (
    <Accordion defaultExpandedKeys={["item-1"]}>
      <AccordionItem id="item-1">
        <AccordionTrigger icon={<ChevronDown />}>
          What is your refund policy?
        </AccordionTrigger>
        <AccordionContent>
          We offer a full refund within 90 days of purchase, no questions asked.
          Just send us an email.
        </AccordionContent>
      </AccordionItem>
      <AccordionItem id="item-2">
        <AccordionTrigger icon={<ChevronDown />}>
          How do I get started?
        </AccordionTrigger>
        <AccordionContent>
          Follow our step-by-step guide to finish setup in under 5 minutes. No
          technical knowledge required.
        </AccordionContent>
      </AccordionItem>
      <AccordionItem id="item-3">
        <AccordionTrigger icon={<ChevronDown />}>
          Do you offer technical support?
        </AccordionTrigger>
        <AccordionContent>
          Yes, we provide support 24/7 via email and live chat. We usually reply
          within 2 hours.
        </AccordionContent>
      </AccordionItem>
    </Accordion>
  );
}

Multiple expansion

Multiple accordion items can be expanded at the same time.

Multiple sections can be open at the same time.

Try opening several sections!

Content of the third section.
accordion.tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@ginga-ui/core";
import { ChevronDown } from "lucide-react";

export function MultipleExpansionExample() {
  return (
    <Accordion
      allowsMultipleExpanded
      defaultExpandedKeys={["item-1", "item-2"]}
    >
      <AccordionItem id="item-1">
        <AccordionTrigger icon={<ChevronDown />}>Section 1</AccordionTrigger>
        <AccordionContent>
          Multiple sections can be open at the same time.
        </AccordionContent>
      </AccordionItem>
      <AccordionItem id="item-2">
        <AccordionTrigger icon={<ChevronDown />}>Section 2</AccordionTrigger>
        <AccordionContent>Try opening several sections!</AccordionContent>
      </AccordionItem>
      <AccordionItem id="item-3">
        <AccordionTrigger icon={<ChevronDown />}>Section 3</AccordionTrigger>
        <AccordionContent>Content of the third section.</AccordionContent>
      </AccordionItem>
    </Accordion>
  );
}

Closed by default

An accordion with all items closed initially.

The answer appears here.

The answer appears here.
accordion.tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@ginga-ui/core";
import { ChevronDown } from "lucide-react";

export function DefaultClosedExample() {
  return (
    <Accordion>
      <AccordionItem id="faq-1">
        <AccordionTrigger icon={<ChevronDown />}>
          Frequently asked question 1
        </AccordionTrigger>
        <AccordionContent>The answer appears here.</AccordionContent>
      </AccordionItem>
      <AccordionItem id="faq-2">
        <AccordionTrigger icon={<ChevronDown />}>
          Frequently asked question 2
        </AccordionTrigger>
        <AccordionContent>The answer appears here.</AccordionContent>
      </AccordionItem>
    </Accordion>
  );
}

Controlled accordion

An accordion whose state is controlled externally.

Changes to the expanded state are logged to the console.

Content of the second item.
accordion.tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@ginga-ui/core";
import { ChevronDown } from "lucide-react";

export function ControlledExample() {
  return (
    <Accordion
      onExpandedChange={(keys) => console.log("Expanded items:", keys)}
    >
      <AccordionItem id="item-1">
        <AccordionTrigger icon={<ChevronDown />}>Item 1</AccordionTrigger>
        <AccordionContent>
          Changes to the expanded state are logged to the console.
        </AccordionContent>
      </AccordionItem>
      <AccordionItem id="item-2">
        <AccordionTrigger icon={<ChevronDown />}>Item 2</AccordionTrigger>
        <AccordionContent>Content of the second item.</AccordionContent>
      </AccordionItem>
    </Accordion>
  );
}

Props

Accordion

NameTypeDefaultDescription
disabledbooleanfalseDisables every item in the accordion.

Also accepts the props of React Aria's DisclosureGroup (opens in a new tab).

AccordionItem

NameTypeDefaultDescription
disabledbooleanfalseDisables the item.
expandedboolean-Whether the item is expanded (controlled). Use it with onExpandedChange.

Also accepts the props of React Aria's Disclosure (opens in a new tab).

AccordionTrigger

NameTypeDefaultDescription
disabledbooleanfalseDisables the trigger.
level2 | 3 | 4 | 5 | 63Level of the heading element that wraps the trigger.
iconReactNode-Icon shown at the end of the trigger. It rotates when expanded.

Also accepts the props of React Aria's Button (opens in a new tab).

AccordionContent

Accepts the props of React Aria's DisclosurePanel (opens in a new tab).