'use client'
import { Accordion } from '@saas-ui/react'
export const AccordionBasic = () => {
  return (
    <Accordion.Root collapsible defaultValue={['b']}>
      {items.map((item, index) => (
        <Accordion.Item key={index} value={item.value}>
          <Accordion.ItemTrigger>{item.title}</Accordion.ItemTrigger>
          <Accordion.ItemContent>{item.text}</Accordion.ItemContent>
        </Accordion.Item>
      ))}
    </Accordion.Root>
  )
}
const items = [
  { value: 'a', title: 'First Item', text: 'Some value 1...' },
  { value: 'b', title: 'Second Item', text: 'Some value 2...' },
  { value: 'c', title: 'Third Item', text: 'Some value 3...' },
]
Parts
import { Accordion } from '@saas-ui/react/accordion'
function Parts() {
  return (
    <Accordion.Root>
      <Accordion.Item>
        <Accordion.ItemTrigger />
        <Accordion.ItemContent />
      </Accordion.Item>
    </Accordion.Root>
  )
}Set the accordion that shows up by default.
Expanded: second-item
'use client'
import { useState } from 'react'
import { Stack, Text } from '@chakra-ui/react'
import { Accordion } from '@saas-ui/react'
export const AccordionControlled = () => {
  const [value, setValue] = useState(['second-item'])
  return (
    <Stack gap="4">
      <Text fontWeight="medium">Expanded: {value.join(', ')}</Text>
      <Accordion.Root value={value} onValueChange={(e) => setValue(e.value)}>
        {items.map((item, index) => (
          <Accordion.Item key={index} value={item.value}>
            <Accordion.ItemTrigger>{item.title}</Accordion.ItemTrigger>
            <Accordion.ItemContent>{item.text}</Accordion.ItemContent>
          </Accordion.Item>
        ))}
      </Accordion.Root>
    </Stack>
  )
}
const items = [
  { value: 'first-item', title: 'First Item', text: 'Some value 1...' },
  { value: 'second-item', title: 'Second Item', text: 'Some value 2...' },
  { value: 'third-item', title: 'Third Item', text: 'Some value 3...' },
]
Use the AccordionItemIcon to add an icon to each accordion item.
Product details
'use client'
import { Heading, Icon, Stack } from '@chakra-ui/react'
import { Accordion } from '@saas-ui/react'
import { LuChartBarStacked, LuTags } from 'react-icons/lu'
export const AccordionWithIcon = () => {
  return (
    <Stack width="full" maxW="400px">
      <Heading size="md">Product details</Heading>
      <Accordion.Root collapsible defaultValue={['info']}>
        {items.map((item) => (
          <Accordion.Item key={item.value} value={item.value}>
            <Accordion.ItemTrigger>
              <Icon fontSize="lg" color="fg.subtle">
                {item.icon}
              </Icon>
              {item.title}
            </Accordion.ItemTrigger>
            <Accordion.ItemContent>{item.content}</Accordion.ItemContent>
          </Accordion.Item>
        ))}
      </Accordion.Root>
    </Stack>
  )
}
const items = [
  {
    value: 'info',
    icon: <LuTags />,
    title: 'Product Info',
    content:
      'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec odio vel dui euismod fermentum.',
  },
  {
    value: 'stats',
    icon: <LuChartBarStacked />,
    title: 'Stats',
    content:
      'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec odio vel dui euismod fermentum.',
  },
]
Use the multiple prop to allow multiple items to be expanded at once.
'use client'
import { Accordion } from '@saas-ui/react'
export const AccordionWithMultiple = () => {
  return (
    <Accordion.Root multiple defaultValue={['b']}>
      {items.map((item, index) => (
        <Accordion.Item key={index} value={item.value}>
          <Accordion.ItemTrigger>{item.title}</Accordion.ItemTrigger>
          <Accordion.ItemContent>{item.text}</Accordion.ItemContent>
        </Accordion.Item>
      ))}
    </Accordion.Root>
  )
}
const items = [
  { value: 'a', title: 'First Item', text: 'Some value 1...' },
  { value: 'b', title: 'Second Item', text: 'Some value 2...' },
  { value: 'c', title: 'Third Item', text: 'Some value 3...' },
]
Use the size prop to change the size of the accordion.
sm
md
lg
'use client'
import { For, Stack, Text } from '@chakra-ui/react'
import { Accordion } from '@saas-ui/react'
export const AccordionSizes = () => {
  return (
    <Stack gap="8">
      <For each={['sm', 'md', 'lg']}>
        {(size) => (
          <Stack gap="2">
            <Text fontWeight="semibold">{size}</Text>
            <Accordion.Root
              size={size}
              key={size}
              collapsible
              defaultValue={['b']}
            >
              {items.map((item, index) => (
                <Accordion.Item key={index} value={item.value}>
                  <Accordion.ItemTrigger>{item.title}</Accordion.ItemTrigger>
                  <Accordion.ItemContent>{item.text}</Accordion.ItemContent>
                </Accordion.Item>
              ))}
            </Accordion.Root>
          </Stack>
        )}
      </For>
    </Stack>
  )
}
const items = [
  { value: 'a', title: 'First Item', text: 'Some value 1...' },
  { value: 'b', title: 'Second Item', text: 'Some value 2...' },
  { value: 'c', title: 'Third Item', text: 'Some value 3...' },
]
Use the variant prop to change the visual style of the accordion. Values can
be either outline, elevated, contained or plain.
outline
subtle
enclosed
plain
'use client'
import { For, Stack, Text } from '@chakra-ui/react'
import { Accordion } from '@saas-ui/react'
export const AccordionVariants = () => {
  return (
    <Stack gap="8">
      <For each={['outline', 'subtle', 'enclosed', 'plain']}>
        {(variant) => (
          <Stack gap="2">
            <Text fontWeight="semibold">{variant}</Text>
            <Accordion.Root
              variant={variant}
              key={variant}
              collapsible
              defaultValue={['b']}
            >
              {items.map((item, index) => (
                <Accordion.Item key={index} value={item.value}>
                  <Accordion.ItemTrigger>{item.title}</Accordion.ItemTrigger>
                  <Accordion.ItemContent>{item.text}</Accordion.ItemContent>
                </Accordion.Item>
              ))}
            </Accordion.Root>
          </Stack>
        )}
      </For>
    </Stack>
  )
}
const items = [
  { value: 'a', title: 'First Item', text: 'Some value 1...' },
  { value: 'b', title: 'Second Item', text: 'Some value 2...' },
  { value: 'c', title: 'Third Item', text: 'Some value 3...' },
]
Pass the disabled prop to disable an accordion item to prevent it from being
expanded or collapsed.
'use client'
import { Accordion } from '@saas-ui/react'
export const AccordionWithDisabledItem = () => {
  return (
    <Accordion.Root collapsible defaultValue={['b']}>
      {items.map((item, index) => (
        <Accordion.Item key={index} value={item.value} disabled={item.disabled}>
          <Accordion.ItemTrigger>{item.title}</Accordion.ItemTrigger>
          <Accordion.ItemContent>{item.text}</Accordion.ItemContent>
        </Accordion.Item>
      ))}
    </Accordion.Root>
  )
}
const items = [
  { value: 'a', title: 'First Item', text: 'Some value 1...' },
  { value: 'b', title: 'Second Item', text: 'Some value 2...' },
  { value: 'c', title: 'Third Item', text: 'Some value 3...', disabled: true },
]
| Prop | Default | Type | 
|---|---|---|
| collapsible  | false | booleanWhether an accordion item can be closed after it has been expanded. | 
| lazyMount  | false | booleanWhether to enable lazy mounting | 
| multiple  | false | booleanWhether multple accordion items can be expanded at the same time. | 
| orientation  | '\'vertical\'' | 'horizontal' | 'vertical'The orientation of the accordion items. | 
| unmountOnExit  | false | booleanWhether to unmount on exit. | 
| colorPalette  | 'gray' | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | 'accent'The color palette of the component | 
| variant  | 'outline' | 'outline' | 'subtle' | 'enclosed' | 'plain'The variant of the component | 
| size  | 'md' | 'sm' | 'md' | 'lg'The size of the component | 
| asChild  | booleanUse the provided child element as the default rendered element, combining their props and behavior.For more details, read our Composition guide. | |
| defaultValue  | string[]The initial value of the accordion when it is first rendered. Use when you do not need to control the state of the accordion. | |
| disabled  | booleanWhether the accordion items are disabled | |
| id  | stringThe unique identifier of the machine. | |
| ids  | Partial<{
  root: string
  item(value: string): string
  itemContent(value: string): string
  itemTrigger(value: string): string
}>The ids of the elements in the accordion. Useful for composition. | |
| onFocusChange  | (details: FocusChangeDetails) => voidThe callback fired when the focused accordion item changes. | |
| onValueChange  | (details: ValueChangeDetails) => voidThe callback fired when the state of expanded/collapsed accordion items changes. | |
| value  | string[]The `value` of the accordion items that are currently being expanded. | 
| Prop | Default | Type | 
|---|---|---|
| value * | stringThe value of the accordion item. | |
| asChild  | booleanUse the provided child element as the default rendered element, combining their props and behavior.For more details, read our Composition guide. | |
| disabled  | booleanWhether the accordion item is disabled. | 
| Prop | Default | Type | 
|---|---|---|
| asChild  | booleanUse the provided child element as the default rendered element, combining their props and behavior.For more details, read our Composition guide. | 
| Prop | Default | Type | 
|---|---|---|
| asChild  | booleanUse the provided child element as the default rendered element, combining their props and behavior.For more details, read our Composition guide. |