Skip to content

Toggle the visibility of two elements without removing them from the document layout

License

Notifications You must be signed in to change notification settings

Vestride/react-stacked-elements

Repository files navigation

react-stacked-elements Build Status

Toggle the visibility of elements without causing a layout shift

This package uses CSS Grid to place items at the same column and row, then toggles their visibility based on the selectedIndex property.

Install

npm install react-stacked-elements

Usage

<StackedElements selectedIndex={isChecked ? 0 : 1}>
  <span>Absolutely</span>
  <span>No</span>
</StackedElements>

Demos

Check them out here https://vestride.github.io/react-stacked-elements/