Skip to Content
文档

网格

用于管理网格布局

SourceStorybook

用法

¥Usage

import { Grid, GridItem } from "@chakra-ui/react"
<Grid>
  <GridItem />
  <GridItem />
</Grid>

示例

¥Examples

列跨度

¥Col Span

colSpan 属性传递给 GridItem 以跨列显示。

¥Pass colSpan prop to GridItem to span across columns.

跨列

¥Spanning Columns

在某些布局中,你可能需要某些网格项跨越特定数量的列或行,而不是均匀分布。

¥In some layouts, you may need certain grid items to span specific amount of columns or rows instead of an even distribution

rowSpan=2
colSpan=2
colSpan=2
colSpan=4

属性

¥Props

PropDefaultType
templateColumns
SystemStyleObject['gridTemplateColumns'] | undefined

autoFlow
SystemStyleObject['gridAutoFlow'] | undefined

autoRows
SystemStyleObject['gridAutoRows'] | undefined

autoColumns
SystemStyleObject['gridAutoColumns'] | undefined

templateRows
SystemStyleObject['gridTemplateRows'] | undefined

templateAreas
SystemStyleObject['gridTemplateAreas'] | undefined

column
SystemStyleObject['gridColumn'] | undefined

row
SystemStyleObject['gridRow'] | undefined

inline
boolean | undefined

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Previous

浮动

Next