You are looking at the documentation of the work in progress Hope UI 1.0, examples and information may be broken or outdated.

Layout

Stack

Arranges content on a horizontal or vertical line.

Import

ts
import { Stack, HStack, VStack } from "@hope-ui/core";
ts
import { Stack, HStack, VStack } from "@hope-ui/core";
  • Stack: Used to add spacing between elements in the horizontal or vertical direction.
  • HStack: Used to add spacing between elements in horizontal direction, and centers them.
  • VStack: Used to add spacing between elements in vertical direction, and centers them.

Usage

To stack elements in one direction only, use the HStack or VStack components. You can also use the Stack component as well and pass the direction prop.

1

2

3

tsx
<HStack color="white" spacing="24px">
<Center boxSize="40px" bg="royalblue">
1
</Center>
<Center boxSize="40px" bg="royalblue">
2
</Center>
<Center boxSize="40px" bg="royalblue">
3
</Center>
</HStack>
tsx
<HStack color="white" spacing="24px">
<Center boxSize="40px" bg="royalblue">
1
</Center>
<Center boxSize="40px" bg="royalblue">
2
</Center>
<Center boxSize="40px" bg="royalblue">
3
</Center>
</HStack>

Responsive direction

To have a responsive direction, simply pass a responsive value to the direction prop of the Stack component.

1

2

3

tsx
<Stack color="white" direction={{ base: "column", md: "row" }} spacing="24px">
<Center boxSize="40px" bg="royalblue">
1
</Center>
<Center boxSize="40px" bg="royalblue">
2
</Center>
<Center boxSize="40px" bg="royalblue">
3
</Center>
</Stack>
tsx
<Stack color="white" direction={{ base: "column", md: "row" }} spacing="24px">
<Center boxSize="40px" bg="royalblue">
1
</Center>
<Center boxSize="40px" bg="royalblue">
2
</Center>
<Center boxSize="40px" bg="royalblue">
3
</Center>
</Stack>

Props

Stack

NameTypeDescription
directionResponsiveValue<Property.FlexDirection>Shorthand for flexDirection style prop.
wrapResponsiveValue<Property.FlexWrap>Shorthand for flexWrap style prop.
alignResponsiveValue<Property.AlignItems>Shorthand for alignItems style prop.
justifyResponsiveValue<Property.JustifyContent>Shorthand for justifyContent style prop.
spacingResponsiveValue<Property.Gap>The space between the stack items.
spacingXResponsiveValue<Property.ColumnGap>The space between the stack items on the X axis.
spacingYResponsiveValue<Property.RowGap>The space between the stack items on the Y axis.

HStack and VStack

NameTypeDescription
reverseResponsiveValue<boolean>Whether the direction should be reversed.
wrapResponsiveValue<Property.FlexWrap>Shorthand for flexWrap style prop.
alignResponsiveValue<Property.AlignItems>Shorthand for alignItems style prop.
justifyResponsiveValue<Property.JustifyContent>Shorthand for justifyContent style prop.
spacingResponsiveValue<Property.Gap>The space between the stack items.
spacingXResponsiveValue<Property.ColumnGap>The space between the stack items on the X axis.
spacingYResponsiveValue<Property.RowGap>The space between the stack items on the Y axis.
Previous
SimpleGrid