Pallas UI
DocsComponents
Core Concepts
    • Introduction
    • Getting Started
    • Theming
    • Color Tokens
    • Spacing & Sizing
    • Layout Guide
    • AspectRatio
    • Box
    • Flex
    • Grid
    • Shapes
Previews
    • Accordion
    • Alert
    • Avatar
    • Badge
    • Breadcrumb
    • Button
    • Carousel
    • Checkbox
    • Combobox
    • Command
    • Date Picker
    • Form
    • Input
    • Input OTP
    • Label
    • MenuBar
    • Modal
    • Popover
    • Progress
    • Radio Group
    • Segmented
    • Select
    • Separator
    • Sheet
    • Sidebar
    • Skeleton
    • Slider
    • Spinner
    • Steps
    • Switch
    • Tabs
    • Textarea
    • Toast
    • Tooltip
    • Typography
  1. Components
  2. Accordion

Accordion

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

Is it accessible?

Is it styled?

Is it animated?

Installation

Install the following dependencies

npm install @radix-ui/react-accordion

Copy and paste the following code into your project

'use client'
import { type Assign, type WithFixedClassName, createStyleContext } from '@pallas-ui/style-context'
import * as RadixAccordion from '@radix-ui/react-accordion'
import { type AccordionVariantProps, accordion } from '@styled-system/recipes'
import type { ComponentProps, JsxStyleProps } from '@styled-system/types'
import type * as React from 'react'
 
const { withProvider, withContext } = createStyleContext(accordion)
 
export type RootProps = WithFixedClassName<
  ComponentProps<typeof RadixAccordion.Root> & {
    collapsible?: boolean
  }
>
 
export const Root = withProvider<
  React.ComponentRef<typeof RadixAccordion.Root>,
  Assign<RootProps, AccordionVariantProps & JsxStyleProps>
>(RadixAccordion.Root, 'root')
 
export const Item = withContext<
  React.ComponentRef<typeof RadixAccordion.Item>,
  Assign<ComponentProps<typeof RadixAccordion.Item>, JsxStyleProps>
>(RadixAccordion.Item, 'item')
 
export const ItemHeader = withContext<
  React.ComponentRef<typeof RadixAccordion.Header>,
  Assign<ComponentProps<typeof RadixAccordion.Header>, JsxStyleProps>
>(RadixAccordion.Header, 'itemHeader')
 
export const ItemTrigger = withContext<
  React.ComponentRef<typeof RadixAccordion.Trigger>,
  Assign<ComponentProps<typeof RadixAccordion.Trigger>, JsxStyleProps>
>(RadixAccordion.Trigger, 'itemTrigger')
 
export const ItemContent = withContext<
  React.ComponentRef<typeof RadixAccordion.Content>,
  Assign<ComponentProps<typeof RadixAccordion.Content>, JsxStyleProps>
>(RadixAccordion.Content, 'itemContent')
 
const Accordion = {
  Root,
  Item,
  ItemHeader,
  ItemTrigger,
  ItemContent,
}
 
export default Accordion

Update the import paths to match your project setup

Usage

import {
  Accordion
} from '@/components/ui/accordion'
<Accordion.root type="single" collapsible>
  <Accordion.Item value="item-1">
    <Accordion.ItemHeader>Is it accessible?</Accordion.ItemHeader>
    <Accordion.ItemTrigger>
            +
    </Accordion.ItemTrigger>
    <Accordion.ItemContent>Yes. It adheres to the WAI-ARIA design pattern.</Accordion.ItemContent>
  </Accordion.Item>
</Accordion>

Examples

Default

Is it accessible?

Is it styled?

Is it animated?

Collapsible

Is it accessible?

Is it styled?

Is it animated?

Controlled

Controlled Item 1

This accordion is controlled with React state. Use the segmented control above to manage it.

Controlled Item 2

Custom Style

Custom Styling Example

Different Icons

Dynamic

How is the accordion accessible?

Can I customize the styling?

How to control the accordion programmatically?

Can I have multiple panels open?

Multiple

Is it accessible?

Is it styled?

Is it animated?

Built with ❤️ by the carbonteq team. The source code is available on GitHub.

© 2025 Pallas UI. All rights reserved.