Grid
Grid is a component for managing grid layouts. It also comes with handy style shorthand.
<Grid gap="md" templateColumns="repeat(4, 1fr)">
<For each={Array.from({ length: 4 })}>
{(_, index) => (
<GridItem
key={index}
bg="bg.contrast"
color="fg.contrast"
minH="16"
h="full"
/>
)}
</For>
</Grid>
Usage
import { Grid, GridItem } from "@yamada-ui/react"
import { Grid, GridItem } from "@/components/ui"
import { Grid, GridItem } from "@workspaces/ui"
<Grid>
<GridItem />
</Grid>
Use Template Areas
<Grid
templateAreas={`
"one one two three"
"four five two six"
"four seven seven eight"
`}
gap="md"
>
<For each={["one", "two", "three", "four", "five", "six", "seven", "eight"]}>
{(area, index) => (
<GridItem
key={index}
bg="bg.contrast"
color="fg.contrast"
minH="16"
h="full"
area={area}
/>
)}
</For>
</Grid>
Spanning Multiple Columns and Rows
<Grid gap="md" templateColumns="repeat(4, 1fr)" templateRows="repeat(3, 1fr)">
<GridItem
bg="bg.contrast"
color="fg.contrast"
minH="16"
h="full"
colSpan={2}
/>
<GridItem
bg="bg.contrast"
color="fg.contrast"
minH="16"
h="full"
colSpan={2}
rowSpan={3}
/>
<GridItem
bg="bg.contrast"
color="fg.contrast"
minH="16"
h="full"
rowStart={2}
rowEnd={4}
/>
<GridItem
bg="bg.contrast"
color="fg.contrast"
minH="16"
h="full"
colStart={2}
colEnd={3}
rowStart={2}
rowEnd={4}
/>
</Grid>
Props
Similar Components
Bleed
Bleed is a component used to extend elements beyond the boundaries of a container.
Box
Box is the most abstract component on which all other components are built. By default, it renders a div element.
Center
Center is a component that aligns the child elements in the center within the component.
Container
Container is a component used as a general division element. By default, it renders the section element.
Flex
Flex is a component that sets flex to Box. Also, convenient style shorthand is available.
Float
Float is a component used to fix elements to the edges of a container.
Group
Group is a component that groups and attaches multiple elements together.
HStack
HStack is used to stack child elements horizontally.