Components

Collapse

The Collapse component is used to put regions of content under a block that users can expand or collapse.

Import

import { Collapse } from '@outfitio/outkit';

Usage

Basic Usage

Changing the startingHeight

Accessibility

  • Use the ariaExpanded prop on the button component to add an aria-expanded attribute, which conveys the expanded or collapsed state to screen reader users.
  • Use the ariaControls prop on the button component, and set its value to the id of the collapsible component

Best Practice

  • The collapse component can be used for information that is lower priority or users don’t need to see all the time
  • It should not be used to hide error messages or other critical information that requires immediate action.

Props

This component doesn't have any custom props.

NameTypeDescription
isOpenbooleanIf true, the content will be visible
animateOpacitybooleanIf true, the opacity of the content will be animated
durationnumberThe animation duration as it expands
startingHeightnumberThe height you want the content in it's collapsed state. Set to 0 by default
endingHeightnumberThe height you want the content in it's expanded state. Set to auto by default
onAnimationEndfuncThe function to be called when the collapse animation starts. It provides the currentHeight as an argument
onAnimationStartfuncThe function to be called when the collapse animation ends. It provides the currentHeight as an argument