The structure of a stack is the following: stack
is your main container, following with each individual stack item. They need to be a direct child of the stack container.
Stack component has a number of different properties for using with a stack
container. There are four in particular that define the overall layout that the component has: direction, alignment, spacing and colors.
Below is a simple example of a button with tailing icon: the button is our stack container following with two direct stack items.
With stack component you can do pretty much everything from media list to sidebar navigation, the possibilities are endless:
Direction refers to whether the stacking of children components is horizontal or vertical. By default the stack component is horizontal, but can be turned vertical by adding the stack-vertical
modifier when using the component.
In most case stack will be horizontal, you can omit the horizontal modifier here as the browser default is row
.
Sometime you will need to force your stack items to be vertically aligned, simply use stack-vertical
modifier.
Alignment refers to how the children components are aligned inside the container by using some flexbox related properties. These options are applied on specific children of the flexbox instead of being applied on the container.
If you want your stack items to have have an equal width, no matter the number of stack items, use stack-flex
.
Each individual stack items can take different properties to help you create complex layout inside your stack container.
Use .stack-flex
to toggle a flex item’s ability to grow to fill available space. In the example below, the middle element uses all available space it can, while allowing the remaining two flex items their necessary space.
You can easily align contents with stack-item-lead
to the left side and with stack-item-tail
to the right side to create your appbar component for example.
Below is a simple example of how to move the first one to the top and the last one to the bottom of a stack container: