For AI agents: the complete documentation index is at llms.txt. Markdown versions are available by appending .md or sending Accept: text/markdown.
Reflex Logo
Docs Logo
Library

/

Disclosure

/

Accordion

Accordion

An accordion is a vertically stacked set of interactive headings that each reveal an associated section of content. The accordion component is made up of accordion, which is the root of the component and takes in an accordion.item, which contains all the contents of the collapsible section.

Basic Example

Styling

Type

We use the type prop to determine whether multiple items can be opened at once. The allowed values for this prop are single and multiple where single will only open one item at a time. The default value for this prop is single.

Default Value

We use the default_value prop to specify which item should open by default. The value for this prop should be any of the unique values set by an accordion.item.

The second accordion item's content

Expand

Collapsible

We use the collapsible prop to allow all items to close. If set to False, an opened item cannot be closed.

Expand

Disable

We use the disabled prop to prevent interaction with the accordion and all its items.

Orientation

We use orientation prop to set the orientation of the accordion to vertical or horizontal. By default, the orientation will be set to vertical. Note that, the orientation prop won't change the visual orientation but the functional orientation of the accordion. This means that for vertical orientation, the up and down arrow keys moves focus between the next or previous item, while for horizontal orientation, the left or right arrow keys moves focus between items.

Variant

Expand

Color Scheme

We use the color_scheme prop to assign a specific color to the accordion background, ignoring the global theme.

Expand

Value

We use the value prop to specify the controlled value of the accordion item that we want to activate. This property should be used in conjunction with the on_value_change event argument.

Expand

AccordionItem

The accordion item contains all the parts of a collapsible section.

Styling

Value

Disable

API Reference

rx.accordion.root

An accordion component.

rx.accordion.root(
rx.accordion.item(
header="First Item",
content="The first accordion item's content",
color_scheme="tomato",
variant="classic",
disabled=False,
radius="none",
),
rx.accordion.item(
header="Second Item",
content="The second accordion item's content",
color_scheme="tomato",
variant="classic",
disabled=False,
radius="none",
),
rx.accordion.item(
header="Third item",
content="The third accordion item's content",
color_scheme="tomato",
variant="classic",
disabled=False,
radius="none",
),
width="300px",
color_scheme="tomato",
variant="classic",
disabled=False,
radius="none",
)
color_scheme
variant
disabled
radius

Props

PropTypeDescription
as_child
bool

Change the default rendered element for the one passed as a child.

color_scheme
"tomato""red""ruby""crimson""pink""plum""purple""violet""iris""indigo""blue""cyan""teal""jade""green""grass""brown""orange""sky""mint""lime""yellow""amber""gold""bronze""gray"

The color scheme of the component.

variant
"classic""soft""surface""outline""ghost"

The variant of the component.

type
"single""multiple"

The type of accordion (single or multiple).

value
Union[str, Sequence]

The value of the item to expand.

default_value
Union[str, Sequence]

The default value of the item to expand.

collapsible
bool

Whether or not the accordion is collapsible.

disabled
bool

Whether or not the accordion is disabled.

dir
"ltr""rtl"

The reading direction of the accordion when applicable.

orientation
"vertical""horizontal"

The orientation of the accordion.

radius
"none""small""medium""large""full"

The radius of the accordion corners.

duration
int

The time in milliseconds to animate open and close.

easing
str

The easing function to use for the animation.

show_dividers
bool

Whether to show divider lines between items.

Valid Children

AccordionItem

Event Triggers

See the full list of default event triggers
TriggerDescription
on_value_changeFired when the opened the accordions changes.

rx.accordion.item

An accordion component.

rx.accordion.root(
rx.accordion.item(
header="Single Item",
content="The accordion item's content",
color_scheme="tomato",
variant="classic",
disabled=False,
),
width="300px",
)
color_scheme
variant
disabled

Props

PropTypeDescription
as_child
bool

Change the default rendered element for the one passed as a child.

color_scheme
"tomato""red""ruby""crimson""pink""plum""purple""violet""iris""indigo""blue""cyan""teal""jade""green""grass""brown""orange""sky""mint""lime""yellow""amber""gold""bronze""gray"

The color scheme of the component.

variant
"classic""soft""surface""outline""ghost"

The variant of the component.

value
str

A unique identifier for the item.

disabled
bool

When true, prevents the user from interacting with the item.

header
Union[Component, str]

The header of the accordion item.

content
Union[str, Component, NoneType]

The content of the accordion item.

Valid Children

AccordionHeaderAccordionTriggerAccordionContent
Built with Reflex