SimpleGrid
SimpleGrid
is a component that makes Grid
simpler and more user-friendly.
<SimpleGrid columns={2} gap="md" w="full">
<For each={Array.from({ length: 4 })}>
{(_, index) => (
<GridItem
key={index}
bg="bg.contrast"
color="fg.contrast"
p="md"
textAlign="center"
>
GridItem
</GridItem>
)}
</For>
</SimpleGrid>
Usage
import { SimpleGrid } from "@yamada-ui/react"
import { SimpleGrid } from "@/components/ui"
import { SimpleGrid } from "@workspaces/ui"
<SimpleGrid />
Adjusting gaps
To adjust gaps, pass values to gap
, rowGap
, and columnGap
.
<SimpleGrid columns={2} columnGap="lg" rowGap="sm" w="full">
<For each={Array.from({ length: 4 })}>
{(_, index) => (
<GridItem
key={index}
bg="bg.contrast"
color="fg.contrast"
p="md"
textAlign="center"
>
GridItem
</GridItem>
)}
</For>
</SimpleGrid>
Adjusting child width
To adjust the width of child elements, pass a value to minChildWidth
.
<SimpleGrid gap="md" minChildWidth={{ base: "3xs", md: "8rem" }} w="full">
<For each={Array.from({ length: 4 })}>
{(_, index) => (
<GridItem
key={index}
bg="bg.contrast"
color="fg.contrast"
p="md"
textAlign="center"
>
GridItem
</GridItem>
)}
</For>
</SimpleGrid>