Skip to main content
K
Last modified: 4/Oct/2024

Collapse

A content area which can be collapsed and expanded.
The children of the Collapse component is CollapseItem.

#Usage

<Collapse defaultKeys={[1]}> <Collapse.CollapseItem header={<div style={{ padding: 16 }}>Obi-Wan</div>} position={1} > <div style={{ padding: 16 }}>R2D2</div> </Collapse.CollapseItem> <Collapse.CollapseItem header="Qui-Gon" position={2}> You must learn the ways of the Force if youre to come with me to Alderaan. </Collapse.CollapseItem> <Collapse.CollapseItem header="Mace" position={3}> You must learn the ways of the Force if youre to come with me to Alderaan. </Collapse.CollapseItem> </Collapse>

#Props

#mode
modeTypes
The animation direction for an item
vertical
#defaultKeys
number[]
Items expanded on load. The position prop needs to be set in the Collapse.Item as well.
[]
#onChange
(key: number) => void
The callback that runs when the active collapse item is changing
#isAccordion
boolean
Decides whether the Collapse is as an accordion (only one item can be open at a time) or not.
#isCollapsedByDefault
boolean
Decides whether the Collapse items are collapsed by default.
false

#CollapseItem Props

#children
React.ReactNode
The content of the component
ReactElement ǀ string
The title of the CollapseItem
#position
number
The id of the Item. Its value is related with the values defined in the defaultKeys prop
#isCollapsible
boolean
true" description="Decides whether the item can collapse or not
#onStateChange
(isOpen: boolean) => void
The callback that runs when the state is changing

#Types

  • CollapseInterface: props of the Collapse component processed by stratus extended by Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>

Read more about types here