Tonic UI
Getting StartedColor ModeColor StyleVersionsContributing
THEME
BordersBreakpointsColorsOutlinesPositionsSpacingSizesShadowsTypography
BUILDING BLOCKS
BoxControlBox
UTILITIES

Collapse

Collapse is used to create regions of content that can expand/collapse with a simple animation. It helps to hide content that's not immediately relevant to the user.

This component uses react-animate-height for animating height.

Import

Usage

Basic usage

EDITABLE EXAMPLE

Changing the startingHeight

EDITABLE EXAMPLE

Props

NameTypeDefaultDescription
isOpenbooleanfalseIf true, the content will be visible.
animateOpacitybooleantrueIf true, the opacity of the content will be animated.
durationnumberThe animation duration as it expands.
startingHeightnumber0The height you want the content in it's collapsed state.
endingHeightnumber'auto'The height you want the content in it's expanded state.
onAnimationEndfunctionA callback which will be called when animation starts. The first argument passed to this callback is an object containing newHeight, the pixel value of the height at which the animation will end.
onAnimationStartfunctionA callback which will be called when animation ends. The first argument passed to this callback is an object containing newHeight, the pixel value of the height at which the animation ended.