bits

Accordion

Organizes content into collapsible sections.

Structure

	<script lang="ts">
  import { Accordion } from "bits-ui";
</script>
 
<Accordion.Root>
  <Accordion.Item>
    <Accordion.Header>
      <Accordion.Trigger />
    </Accordion.Header>
    <Accordion.Content />
  </Accordion.Item>
</Accordion.Root>
	<script lang="ts">
  import { Accordion } from "bits-ui";
</script>
 
<Accordion.Root>
  <Accordion.Item>
    <Accordion.Header>
      <Accordion.Trigger />
    </Accordion.Header>
    <Accordion.Content />
  </Accordion.Item>
</Accordion.Root>

Component API

Accordion.Root

The root accordion component used to set and manage the state of the accordion.

Property Type Description
multiple
boolean

Whether or not multiple accordion items can be active at the same time.

Default: false
disabled
boolean

Whether or not the accordion is disabled.

Default: false
value
union

The active accordion item value.

Default:  —— undefined
onValueChange
function

A callback function called when the active accordion item value changes.

Default:  —— undefined
value
union

The active accordion item value when multiple is true.

Default:  —— undefined
onValueChange
function

A callback function called when the active accordion item value changes when multiple is true.

Default:  —— undefined
Data Attribute Description/Value
data-orientation

The orientation of the accordion.

Value: 'horizontal' | 'vertical'
data-bits-accordion-root

Present on the root element.

Value: ''

Accordion.Item

An accordion item.

Property Type Description
asChild
boolean

Whether to use render delegation with this component or not.

Default: false
value
string

The value of the accordion item.

Default:  —— undefined
disabled
boolean

Whether or not the accordion item is disabled.

Default: false
Data Attribute Description/Value
data-state

The state of the accordion item.

Value: 'open' | 'closed'
data-disabled

Present when the accordion item is disabled.

Value: ''
data-bits-accordion-item

Present on the item element.

Value: ''

Accordion.Trigger

The accordion item trigger, which opens and closes the accordion item.

Property Type Description
asChild
boolean

Whether to use render delegation with this component or not.

Default: false
Data Attribute Description/Value
data-state

The state of the accordion item.

Value: 'open' | 'closed'
data-disabled

Present when the accordion item is disabled.

Value: ''
data-value

The value of the accordion item.

Value: ''
data-bits-accordion-trigger

Present on the trigger element.

Value: ''

Accordion.Content

The accordion item content, which is displayed when the item is open.

Property Type Description
asChild
boolean

Whether to use render delegation with this component or not.

Default: false
Data Attribute Description/Value
data-state

The state of the accordion item.

Value: 'open' | 'closed'
data-disabled

Present when the accordion item is disabled.

Value: ''
data-value

The value of the accordion item.

Value: ''
data-bits-accordion-content

Present on the content element.

Value: ''