SimpleGrid
SimpleGridは、Gridをより使いやすくシンプルにしたコンポーネントです。
<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>
使い方
import { SimpleGrid } from "@yamada-ui/react"
import { SimpleGrid } from "@/components/ui"
import { SimpleGrid } from "@workspaces/ui"
<SimpleGrid />
間隔を調整する
間隔を調整する場合は、gap、rowGap、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>
子要素の幅を調整する
子要素の幅を調整する場合は、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>
Props
類似のコンポーネント
Bleed
Bleedは、要素をコンテナの境界から外すために使用されるコンポーネントです。
Box
Boxは、他のすべてのコンポーネントがその上に構築される最も抽象的なコンポーネントです。デフォルトでは、div要素をレンダリングします。
Center
Centerは、コンポーネント内の子要素を中央に配置するコンポーネントです。
Container
Containerは、汎用的な区分要素として使用するコンポーネントです。デフォルトでは、section要素をレンダリングします。
Flex
Flexは、Boxにflexを設定したコンポーネントです。また、便利なスタイルのショートハンドが用意されています。
Float
Floatは、要素をコンテナの端に固定するために使用されるコンポーネントです。
Grid
Gridは、グリッドレイアウトを管理するためのコンポーネントです。また、便利なスタイルのショートハンドが用意されています。
Group
Groupは、複数の要素をまとめて扱うためのコンポーネントです。