Grid
使用固定列数或自动适配最小宽度的 CSS 网格。
Tokens
Components
Motion
Themes
Icons
Layout
导入
“导入”部分import { Grid, GridItem } from "@pelagornis/page/components";示例
“示例”部分上方预览渲染的就是这个文件。把它复制到 src/components/ 即可开始使用。
import { Box, Grid, GridItem, Text } from "@pelagornis/page/components";
const items = ["Tokens", "Components", "Motion", "Themes", "Icons", "Layout"];
export default function GridDemo() { return ( <Grid minItem="foundationSize2560" gap="sizeMedium" className="w-full"> {items.map((item) => ( <GridItem key={item}> <Box padding="sizeLarge" background="backgroundSurface" radius="roundedLarge"> <Text variant="subtitleMd">{item}</Text> </Box> </GridItem> ))} </Grid> );}在 MDX 中使用
“在 MDX 中使用”部分Grid 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。
---title: Example---
import { Grid } from "@pelagornis/page/components";
<Grid columns={3} gap="sizeMedium"> <div>One</div> <div>Two</div> <div>Three</div></Grid>在 Markdoc 中使用
“在 Markdoc 中使用”部分pageMarkdoc() 会为这个组件注册 grid 标签。在 markdoc.config.mjs 中添加一次预设(见在 Markdoc 中使用),就能在任意 .mdoc 页面中使用该标签。
{% grid columns=3 gap="sizeMedium" %}One
Two
Three{% /grid %}属性的名称和取值与 React props 相同。
结构
“结构”部分组件的组成部分,以及每个部分渲染的 data-refineui 角色。
| 部件 | 角色 |
|---|---|
root | grid |
item | grid-item |
参考
“参考”部分- 设计指南和令牌细节见 RefineUI · Grid。
- 通用规则见在 MDX 中使用和在 Markdoc 中使用。