Use the flexbox utility classes to control various flexbox properties. These are especially useful when combined with layout grid classes.
For these utility classes to work, first create a flex container — you can use the .ds-u-display--flex
utility class — then apply these utility classes to the container's direct children elements.
Flex direction
Use the flex-direction
utility class on a flexbox container to change the alignment of its child elements on the main axis (x-axis by default).
The CSS
flex-direction
property defines how the browser distributes space between and around content items along the main axis of their container. — MDN
Format: .ds-u-flex-direction--[row|column|row-reverse|column-reverse]
Responsive format: .ds-u-[breakpoint]-flex-direction--[row|column|row-reverse|column-reverse]
Justify content
Use the justify-content
utility class on a flexbox container to change the alignment of its child elements on the main axis (x-axis by default).
The CSS
justify-content
property defines how the browser distributes space between and around content items along the main axis of their container. — MDN
Format: .ds-u-justify-content--[start|end|center|between|around]
Responsive format: .ds-u-[breakpoint]-justify-content--[start|end|center|between|around]
Align items
Use the align-items
utility class on a flexbox container to change the alignment of its child elements on the cross axis (y-axis by default).
The CSS
align-items
property defines how the browser distributes space between and around flex items along the cross-axis of their container. This means it works likejustify-content
but in the perpendicular direction. — MDN
Format: .ds-u-align-items--[start|end|center|baseline|stretch]
Responsive format: .ds-u-[breakpoint]-align-items--[start|end|center|baseline|stretch]
Flex-wrap
Use the flex-wrap
utility class on a flexbox container to change how its child elements wrap.
The CSS
flex-wrap
property specifies whether flex items are forced into a single line or can be wrapped onto multiple lines. If wrapping is allowed, this property also enables you to control the direction in which lines are stacked. — MDN
Format: .ds-u-flex-wrap--[nowrap|wrap|reverse]
Responsive format: .ds-u-[breakpoint]-flex-wrap--[nowrap|wrap|reverse]
Responsive flexbox
Use a breakpoint prefix to change the flexbox at specific breakpoints.