Skip to content

Grid 宫格

宫格可以在水平方向上把页面分隔成等宽度的区块,用于展示内容或进行页面导航。

基础用法

自定义列数

自定义内容

正方形格子

格子间距

内容横排

页面导航

徽章提示

API

Grid Props

参数说明类型默认值
column-num列数number | string4
icon-size图标大小,默认单位为pxnumber | string28px
gutter格子之间的间距,默认单位为pxnumber | string0
border是否显示边框booleantrue
center是否将格子内容居中显示booleantrue
square是否将格子固定为正方形booleanfalse
clickable是否开启格子点击反馈booleanfalse
direction格子内容排列的方向,可选值为 horizontalstringvertical
reverse是否调换图标和文本的位置booleanfalse

GridItem Props

参数说明类型默认值
text文字string-
icon图标名称或图片链接,等同于 Icon 组件的 name 属性string-
icon-prefix图标类名前缀,等同于 Icon 组件的 class-prefix 属性stringr-icon
icon-color图标颜色,等同于 Icon 组件的 color 属性string-
dot是否显示图标右上角小红点booleanfalse
badge图标右上角徽标的内容number | string-
badge-props自定义徽标的属性,传入的对象会被透传给 Badge 组件的 propsBadgeProps-
url点击后跳转的链接地址string-
to点击后跳转的目标路由对象,等同于 Vue Router 的 to 属性string | object-
replace是否在跳转时替换当前页面历史booleanfalse

GridItem Events

事件名说明回调参数
click点击格子时触发event: MouseEvent

GridItem Slots

名称说明
default自定义宫格的所有内容
icon自定义图标
text自定义文字

类型定义

组件导出以下类型定义:

ts
import type { GridProps, GridDirection, GridItemProps } from 'ryxon'

主题定制

样式变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件

名称默认值描述
--r-grid-item-content-paddingvar(--r-padding-md) var(--r-padding-xs)-
--r-grid-item-content-backgroundvar(--r-background-2)-
--r-grid-item-content-active-colorvar(--r-active-color)-
--r-grid-item-icon-size28px-
--r-grid-item-text-colorvar(--r-text-color)-
--r-grid-item-text-font-sizevar(--r-font-size-sm)-

Released under the MIT License.