Stack

Lay out components with consistent spacing in a row or column.

Stack

To implement Stack component into your project you’ll need to add the import:

import Stack from "@kiwicom/orbit-components/lib/Stack";

After adding import into your project you can use it simply like:

<Stack>
<Button>My button</Button>
<Button iconRight={<ChevronDown />} />
</Stack>

Props

Table below contains all types of the props available in Stack component.

NameTypeDefaultDescription
asstring"div"The string used for the root node.
alignenum"start"The align-items and align-content of the Stack.
basisstringautoSpecifies the basis value of flex-basis.
childrenReact.NodeContent of the Stack.
dataTeststringOptional prop for testing purposes.
desktopObjectObject for setting up properties for the desktop viewport. See Media queries
directionenumThe flex-direction of the Stack. See Functional specs
flexbooleantrueIf true or you specify some flex attribute, the Stack will use flex attributes.
growbooleantrueIf true, the Stack will have flex-grow set to 1, otherwise it will be 0.
inlinebooleanfalseIf true, the Stack will have display set to inline-flex, otherwise it will be flex.
justifyenum"start"The justify-content of the Stack.
largeDesktopObjectObject for setting up properties for the largeDesktop viewport. See Media queries
largeMobileObjectObject for setting up properties for the largeMobile viewport. See Media queries
mediumMobileObjectObject for setting up properties for the mediumMobile viewport. See Media queries
shrinkbooleanfalseIf true, the Stack will have flex-shrink set to 1.
spacingspacing"medium"The spacing between its children.
spaceAfterenumAdditional padding to bottom of the Stack. See this doc
tabletObjectObject for setting up properties for the tablet viewport. See Media queries
wrapbooleanfalseIf true, the Stack will have flex-wrap set to wrap, otherwise it will be nowrap.
legacybooleanfalseIf true, the Stack will be using margins instead of gap

Media Queries

When you need to specify some different behaviour of the Stack component on different viewport, you can use properties for it. There are mediumMobile, largeMobile, tablet, desktop and largeDesktop available and it behaves the same as mediaQueries functions. All this properties - objects have the some own properties and none is required.

NameTypeDefaultDescription
alignenum"start"The align-items and align-content of the Stack.
basisstringautoSpecifies the basis value of flex-basis.
directionenum"row"The flex-direction of the Stack.
growbooleantrueIf true, the Stack will have flex-grow set to 1, otherwise it will be 0.
inlinebooleanfalseIf true, the Stack will have display set to inline-flex, otherwise it will be flex.
justifyenum"start"The justify-content of the Stack.
shrinkbooleantrueIf false, the Stack will have flex-shrink set to 0.
spacingspacingThe spacing between its children.
spaceAfterenumAdditional padding to bottom of the Stack. See this doc
wrapbooleanfalseIf true, the Stack will have flex-wrap set to wrap, otherwise it will be nowrap.

Functional specs

  • The default behaviour for the Stack component is to not be a flexbox container. It means that by default it’s nesting children natively (below each other) and it won’t use any flex CSS properties.

  • If you specify some property (except children, spaceAfter, dataTest and spacing) it will become a flexbox container and the flex-direction: row will be used.

enum

justifydirectionalign
"start""row""start"
"end""column""end"
"center""row-reverse""center"
"between""column-reverse""stretch"
"around"

spacing

namesize on 992px - ∞
"none"null
"XXXSmall"2px
"XXSmall"4px
"XSmall"8px
"small"12px
"medium"16px
"large"24px
"XLarge"32px
"XXLarge"40px