Stack Styled

React component to make stack layouts easy: adds whitespace horizontal and vertical whitespace between each child element but not around the container. Based on styled-system and CSS Grid. We recommend to use this component with Rebass Grid.

Installation

npm install stack-styled
import Stack from 'stack-styled'

All props except minColumnWidth and numColumns are coming from styled.

Default scale

012345678
0px4px8px16px32px64px128px256px512px

Examples

Vertical stack (default) with 8px gap:

Multiline stack:

Responsive gap (8px, 16px, 32px depending on the viewport width):

Responsive column layout:

You can also use gridRowGap and gridColumnGap props.

Accepts styled-system spacing props, like mt or mb:

You can also use it as a generic CSS Grid component:

_All styled-system’s Space, Layout, Flexbox and Grid Layout props are available.

Responsive buttons (full width on small screens, horizontally stacked on larger screens):

More responsive buttons (vertically stacked on small screens, 2×2 grid on larger screens):

Medium-style article layout:

Down the Rabbit Hole

Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, “and what is the use of a book,” thought Alice “without pictures or conversation?”

So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.