Grid
Provides columns, spacing, borders and direction for grid items.
Import
Use <hui-grid> after configuring uni-app easycom. Import public types and functions from @nscode/handy-uni. Ordinary Vue applications install the @nscode/handy-uni/web preview plugin.
Examples
Each example is standalone. Controls show the current value or event result on the page.
<template>
<view>
<hui-space direction="vertical" fill>
<hui-grid custom-class="hui-space__item" :columns="3" square clickable
><hui-grid-item
v-for="index in 6"
:key="index"
icon="star"
:text="'入口 / Entry ' + index"
:badge="index === 1 ? 10 : undefined"
@click="lastEvent = String(index)"
/></hui-grid>
<hui-grid
custom-class="hui-space__item"
:columns="2"
:gutter="8"
:border="false"
direction="horizontal"
><hui-grid-item icon="home" text="首页 / Home" /><hui-grid-item
icon="user"
text="用户 / User"
disabled
/></hui-grid>
<text class="hui-space__item">{{ lastEvent }}</text>
</hui-space>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('尚无事件 / No event')
</script>
Props
| Prop | Type | Default | Details |
|---|---|---|---|
columns | number | 4 | Positive number of columns. |
gutter | number | 0 | Grid spacing in px. |
border | boolean | true | Displays separators. |
square | boolean | false | Keeps cells square. |
center | boolean | true | Centers item content. |
direction | GridDirection | 'vertical' | Layout or scrolling direction. |
clickable | boolean | false | Enables click or keyboard interaction. |
iconSize | number | 28 | Icon size in px. |
Root classes and styles use customClass and customStyle. Numbers representing dimensions use px; durations use ms unless explicitly documented.
Events
None.
Slots
| Slot | Scope |
|---|---|
default | — |
Methods
None.
Types
GridDirection、GridProps、GridEmits.
Theme variables
--hui-grid-icon-size controls the default icons and takes priority over iconSize. When unset, iconSize supplies the fallback, which defaults to 28px. Set it through the Grid's customStyle or an ancestor style.
Platform notes
Supports H5, WeChat mini-program, App-vue and ordinary Vue 3 Web through shared platform components. Unit tests do not replace device acceptance; verify touch, screen readers, deactivation and native rendering on each target.
Device smoke checklist.