HStack component uses flexbox to lay content out in a row.
On web only HStack is essentially the same component as Box, because Box by default has flexbox enabled (display: flex
) and takes row
as its initial flex-direction
value.
You should use HStack when:
- you want to lay content out in columns that are sized to their content
- you want to add gaps between columns
- you want to lay content out in columns that fill the available space within the parent container
- you need columns of proportionate size to each other (also known as a ratio-based layout)
Note
If you want to lay out children in equal width columns, or with repeated rows of columns of custom sizes, you should use Grid instead.
Columns Sized to Content
Loading...
Columns with Gaps
Loading...
Columns that Fill the Available Space
Loading...
Columns that Have Proportionate Sizes
Loading...
A11y
Has the same accessibility requirements as Box.
Responsive Styles
Web only You can create responsive layouts by passing a configuration object to each supported property of HStack and specify unique styles for phones, tablets, or desktops.
Please note, there are no default responsive styles for Box. This is an additive feature that you will need to configure yourself.
Supported Properties
- Padding
- Margin
- Gap
- Flex styles (justify content, align content, align items, align self, flex direction, and flex wrap)
- Display
- Visibility
Usage
Loading...