Skip to main content
Kaleidoscope

Expandable

Animate the height of an element expanding and collapsing

Toggle

Simple button to toggle open/closed. Requires using render props to pass a ref to the element that you want Expandable to animate to/from the height of. The transition status is also passed as one of the render props, so you can change styling based on the transition state.

Editable example

Dismiss

Expandable also works going in one direction for dismissable content.

Editable example

Timing

Set a different duration using the timeout prop. Default to AnimationDuration.Medium.

Editable example

Custom element

Pass a custom element for the element that expands/contracts. This is useful for when the element has a box shadow and including it as a child would cut off the shadow because the expandable element has overflow: hidden; while animating.

Editable example

Accessibility

Expandable is generic and doesn't handle any accessibility attributes, so make sure to provide appropriate ones depending on the type of experience you're creating. An accordion will require different roles and attributes to an error message that animates in/out. As a rule of thumb, consult the WAI-ARIA spec for the type of component you're creating.