Flex
Flex is a component that sets flex to Box. Also, convenient style shorthand is available.
<Flex gap="md">
{Array.from({ length: 4 }).map((_, index) => (
<Box key={index} bg="bg.contrast" color="fg.contrast" p="md">
Box
</Box>
))}
</Flex>
Usage
import { Flex } from "@yamada-ui/react"
import { Flex } from "@/components/ui"
import { Flex } from "@workspaces/ui"
<Flex />
Direction
<Flex direction="column" gap="md">
{Array.from({ length: 4 }).map((_, index) => (
<Box key={index} bg="bg.contrast" color="fg.contrast" p="md">
Box
</Box>
))}
</Flex>
Align
<Flex align="center" gap="md">
<For each={["sm", "md", "lg"]}>
{(p, index) => (
<Box key={index} bg="bg.contrast" color="fg.contrast" p={p}>
Box
</Box>
)}
</For>
</Flex>
Justify
<Flex justify="space-between" gap="md">
{Array.from({ length: 4 }).map((_, index) => (
<Box key={index} bg="bg.contrast" color="fg.contrast" p="md">
Box
</Box>
))}
</Flex>
Wrap
<Flex wrap="wrap" gap="md" maxW="xs">
{Array.from({ length: 4 }).map((_, index) => (
<Box key={index} bg="bg.contrast" color="fg.contrast" p="md">
Box
</Box>
))}
</Flex>
Use spaces
<Flex w="full" gap="md">
<Box bg="bg.contrast" color="fg.contrast" p="md">
Box
</Box>
<Spacer />
<Box bg="bg.contrast" color="fg.contrast" p="md">
Box
</Box>
</Flex>
Props
Similar Components
ZStack
ZStack is used to stack child elements in depth.
VStack
VStack is used to stack child elements vertically.
Wrap
Wrap is a component that has wrap set on Flex. It inherits convenient style shorthand from Flex.
Stack
Stack is a component that groups elements and provides spacing between child elements.
Spacer
Spacer is a component used to add space between elements.
SimpleGrid
SimpleGrid is a component that makes Grid simpler and more user-friendly.
Separator
Separator is a component that represents a division between elements.
Group
Group is a component that groups and attaches multiple elements together.