Skip to content
Harness Design System Harness Design System Harness Design System

Accordion

beta

The Accordion allows content to be hidden or displayed by clicking a trigger. Multiple items can be shown simultaneously, or restricted to a single item using the type prop.

Usage

import { Accordion } from '@harnessio/ui/components'
//...
return (
<Accordion.Root type="multiple" defaultValue={["item1"]} size="md">
<Accordion.Item value="item1">
<Accordion.Trigger>Trigger text</Accordion.Trigger>
<Accordion.Content>
<p>This is the content</p>
</Accordion.Content>
</Accordion.Item>
</Accordion.Root>
)

Anatomy

All parts of the Accordion component can be imported and composed as required.

<Accordion.Root>
<Accordion.Item>
<Accordion.Trigger />
<Accordion.Content />
</Accordion.Item>
</Accordion.Root>

API Reference

Root

The Accordion.Root component wraps and controls the Accordion.Items. The type prop controls whether the accordion allows the display of multiple items or a single item. The accordion can be either controlled or uncontrolled. By default, the accordion is uncontrolled and will manage its own internal state. When the value and onValueChange props are supplied, the accordion becomes controlled and state is handled externally.

PropRequiredDefaultType
typetruesingle'single' | 'multiple'
collapsiblefalsefalseboolean
defaultValuefalsestring | string[]
disabledfalsefalseboolean
onValueChangefalse(newValue: string | string[]) => void
valuefalsestring | string[]
sizefalsedefault'default' | 'md'
indicatorPositionfalseright'left' | 'right'

Item

The Accordion.Item component represents an individual collapsible panel consisting of a trigger and content to display. The value prop is required and can be thought of as the identifier of the individual Accordion.Item.

PropRequiredDefaultType
valuetruestring
asChildfalsefalseboolean
disabledfalsefalseboolean

Trigger

The Accordion.Trigger component displays the item with a chevron disclosure icon.

PropRequiredDefaultType
childrentrueReactNode
asChildfalsefalseboolean
prefixfalseReactNode
suffixfalseReactNode

Content

The Accordion.Content component displays the item contents when triggered using the Accordion.Trigger.

PropRequiredDefaultType
childrentrueReactNode
asChildfalsefalseboolean