Stack is a 1-dimensional layout system with options to control the direction, spacing, distribution and relative sizing of its children elements.
Usage
import { Stack } from 'nr1'
Examples
Basic
<div className="nr1-Example--stack"> <div className="nr1-Example--stack--directionHorizontal"> <span className="nr1-Example--stack--title">Horizontal (default)</span> <Stack preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div></div>
Direction
<div className="nr1-Example--stack"> <div className="nr1-Example--stack--directionHorizontal"> <span className="nr1-Example--stack--title">Horizontal (default)</span> <Stack directionType={Stack.DIRECTION_TYPE.HORIZONTAL} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--directionVertical"> <span className="nr1-Example--stack--title">Vertical</span> <Stack directionType={Stack.DIRECTION_TYPE.VERTICAL} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div></div>
Gap
<div className="nr1-Example--stack"> <div className="nr1-Example--stack--gapNone"> <span className="nr1-Example--stack--title">None</span> <Stack gapType={Stack.GAP_TYPE.NONE} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--gapSmall"> <span className="nr1-Example--stack--title">Small</span> <Stack gapType={Stack.GAP_TYPE.SMALL} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--gapMedium"> <span className="nr1-Example--stack--title">Medium (default)</span> <Stack gapType={Stack.GAP_TYPE.MEDIUM} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--gapLarge"> <span className="nr1-Example--stack--title">Large</span> <Stack gapType={Stack.GAP_TYPE.LARGE} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--gapExtraLarge"> <span className="nr1-Example--stack--title">Extra large</span> <Stack gapType={Stack.GAP_TYPE.EXTRA_LARGE} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div></div>
Horizontal alignment
<div className="nr1-Example--stack"> <div className="nr1-Example--stack--horizontalAlignmentLeft"> <span className="nr1-Example--stack--title">Left (default)</span> <Stack horizontalType={Stack.HORIZONTAL_TYPE.LEFT} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--horizontalAlignmentCenter"> <span className="nr1-Example--stack--title">Center</span> <Stack horizontalType={Stack.HORIZONTAL_TYPE.CENTER} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--horizontalAlignmentRight"> <span className="nr1-Example--stack--title">Right</span> <Stack horizontalType={Stack.HORIZONTAL_TYPE.RIGHT} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--horizontalAlignmentFill"> <span className="nr1-Example--stack--title">Fill</span> <Stack horizontalType={Stack.HORIZONTAL_TYPE.FILL} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--horizontalAlignmentFillEvenly"> <span className="nr1-Example--stack--title">Fill evenly</span> <Stack horizontalType={Stack.HORIZONTAL_TYPE.FILL_EVENLY} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div></div>
Vertical alignment
<div className="nr1-Example--stack"> <div className="nr1-Example--stack--verticalAlignmentTop"> <span className="nr1-Example--stack--title">Top (default)</span> <Stack verticalType={Stack.VERTICAL_TYPE.TOP} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--verticalAlignmentCenter"> <span className="nr1-Example--stack--title">Center</span> <Stack verticalType={Stack.VERTICAL_TYPE.CENTER} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--verticalAlignmentBottom"> <span className="nr1-Example--stack--title">Bottom</span> <Stack verticalType={Stack.VERTICAL_TYPE.BOTTOM} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--verticalAlignmentFill"> <span className="nr1-Example--stack--title">Fill</span> <Stack verticalType={Stack.VERTICAL_TYPE.FILL} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div>
<div className="nr1-Example--stack--verticalAlignmentFillEvenly"> <span className="nr1-Example--stack--title">Fill evenly</span> <Stack verticalType={Stack.VERTICAL_TYPE.FILL_EVENLY} preview> <StackItem> <div className="nr1-Box--a">1</div> </StackItem> <StackItem> <div className="nr1-Box--b">2</div> </StackItem> <StackItem> <div className="nr1-Box--c">3</div> </StackItem> </Stack> </div></div>
Props
REQUIREDnode | Stack items to display. |
string | Appends class names to the component.Should be used only for positioning and spacing purposes. |
enum | Direction of the stack items. <One of |
boolean | Expands the stack to occupy all available height. |
boolean | Expands the stack to occupy all available width. |
enum | Space between each stack item. <One of |
enum | Sets the horizontal alignment and distribution of the stack items. <One of |
boolean | Visually draws the boxes of the Stack and its StackItems. |
enum[] | Spacing property. Spacing is defined as a tuple of zero to four values, which follow the same conventions as CSS properties like <Array of |
object | Inline style for custom styling. |
string | Adds a Note: You might not see |
enum | Sets the vertical alignment and distribution of the stack items. <One of |