Accordion
Usage
Common Characteristics
All accordions have a label that toggles content below it to show or hide.
A 150ms transition is used to expand the content area down, and 75ms to collapse it up.
Filter Accordion
The filter accordion accommodates a clear function that clears all selections within a filter category. It is hidden when there are no selections.
The content panel height can be specified as needed, and supports internal scrolling if needed. Expanding a content panel does not change the state of any other filter section.
Menu Accordion
Each menu accordion content panel accommodates the height of its content and does not allow internal scrolling. Expanding one content panel collapses any other expanded section.
Code
Default Accordion
Accordion Closed
Accordion Items are all open by default unless open is set to false.
Open an Accordion Item
To set an Accordion Item to open by default, set defaultOpen to true on that item.
Open all Accordion Items
collapseSiblings
prop has to be set when using open
to prevent other accordion items closing when closing one of the items. Otherwise it will have confusing behavior.
Accordion with an onChange Callback Function
Explicitly adding ids to Accordion Item/Input components is recommended. UUIDs are generated by default.
Menu Accordion
Filter Accordion
Accordion Input / Filter Accordion Variant
Clearble Accordion Input
The Accordion.Input is a controlled component, since it is meant to be used with inputs as children. To use the clearble/onClear feature, manage the state of the component from your app. The onClear function returns a boolean value: true when it is clicked.
Accordion Props
property | propType | required | default | description |
---|---|---|---|---|
open | bool | - | false | |
id | string | - | - |
Accordion.Item Props
property | propType | required | default | description |
---|---|---|---|---|
isOpen | bool | - | true | |
triggerTag | string | - | 'div' | |
id | string | - | - | |
triggerClassName | string | - | - | |
children | node | - | - | |
defaultOpen | bool | - | - | |
title | string | - | - | |
variant | string | - | - | |
onClear | func | - | - | |
onChange | func | - | - | |
clearable | bool | - | - |
Accordion.Input Props
property | propType | required | default | description |
---|---|---|---|---|
id | string | - | - | |
children | node | - | - | |
onClear | func | - | - | |
defaultOpen | bool | - | - | |
onChange | func | - | - | |
clearable | bool | - | - | |
onSubmit | func | - | - |