Skip to content
Mesh
1.1.1

Expander

The Expander is used for hiding and showing information.

Installation

bash
npm install @nib-components/expander

Usage

jsx
import Expander from '@nib-components/expander';

Interactive demo

jsx

Props

PropTypeDefaultDescription
expandedbooleanWhether the expandable section is hidden or not.
onBeforeExpandfunctionA function called when the expander starts expanding.
onBeforeCollapsefunctionA function called when the expander starts collapsing.

Considerations

Don't use top-level vertical margins

Refrain from using vertical margins at the top level inside the Expander component. The animation does not account for margins in the calculated height and will cause a jump at the end of the animation.

An alternative is the Accordion component, which we encourage as it allows search engines to see hidden content. Also, be cautious of unnecessarily hiding information from the user. If in doubt, use the Accordion.

If you are using the Expander component to hide and show a number of items, consider using the Expander Group component from the interactive demo to control the behaviour of the group.