Cell cell
introduce
A cell is a single display item in the list.
Code Demo
Basic usage
Cell can be used alone or in combination with CellGroup. CellGroup can provide upper and lower outer borders for Cell.
<z-cell-group>
<z-cell title="cell" value="content" />
<z-cell title="cell" value="content" label="description information" />
</z-cell-group>
Card style
Cells can be converted to rounded card style through the inset property of CellGroup.
<z-cell-group inset>
<z-cell title="cell" value="content" />
<z-cell title="cell" value="content" label="description information" />
</z-cell-group>
Cell size
The size of the cell can be controlled through the size property.
<z-cell title="cell" value="content" size="large" />
<z-cell title="cell" value="content" size="large" label="description information" />
Display icon
Display the icon to the left of the title via the icon attribute.
<z-cell-group>
<z-cell title="cell" value="content" icon="appstore" />
<z-cell title="cell" value="content" icon="setting" />
</z-cell-group>
Show arrow
After setting the is-link property, an arrow will be displayed on the right side of the cell, and the arrow direction can be controlled through the arrow-direction property.
<z-cell title="cell" is-link />
<z-cell title="cell" is-link value="content" />
<z-cell title="cell" is-link arrow-direction="down" value="content" />
Group title
The group title can be specified through the title attribute of CellGroup.
<z-cell-group title="Group 1">
<z-cell title="cell" value="content" />
</z-cell-group>
<z-cell-group title="Group 2">
<z-cell title="cell" value="content" />
</z-cell-group>
Using slots
If the above usage does not meet your needs, you can use slots to customize the content.
<z-cell value="content" is-link>
<!-- Use the title slot to customize the title -->
<template #title>
<text class="custom-title">Cell</text>
<z-tag type="primary">tag</z-tag>
</template>
</z-cell>
<z-cell title="cell" icon="creditcard">
<!-- Use the right-icon slot to customize the right icon -->
<template #right-icon>
<z-icon name="search" class="search-icon" />
</template>
</z-cell>
<style lang="scss" scoped>
.demo-cell {
.custom-title {
margin-right: 10rpx;
}
}
</style>
Vertically centered
The left and right contents of the Cell can be vertically centered through the center attribute.
<z-cell center title="cell" value="content" label="description information" />
API
CellGroup Props
| Parameters | Description | Type | Default value |
|---|---|---|---|
| title | Group title | string | - |
| inset | Whether to display rounded card style | boolean | false |
| border | Whether to display the outer border | boolean | true |
Cell Props
| Parameters | Description | Type | Default value |
|---|---|---|---|
| title | left title | number | string | - |
| value | Right content | number | string | - |
| label | Description information below the title | string | - |
| size | Cell size, optional values are large normal | string | - |
| icon | The icon name or image link on the left, which is equivalent to the name attribute of the Icon component | string | - |
| icon-prefix | Icon class name prefix, equivalent to the class-prefix attribute of the Icon component | string | z-icon |
| border | Whether to display the inner border | boolean | true |
| clickable | Whether to enable click feedback | boolean | null |
| is-link | Whether to display the right arrow and enable click feedback | boolean | false |
| required | Whether to display the required asterisk in the form | boolean | false |
| center | Whether to center the content vertically | boolean | false |
| arrow-direction | Arrow direction, optional values are left up down | string | right |
| title-style | Additional style for left title | string | Array | object | - |
| title-class | Additional class name for left title | string | Array | object | - |
| value-class | Additional class name of the right content | string | Array | object | - |
| label-class | Description information additional class name | string | Array | object | - |
Cell Events
| Event name | Description | Callback parameters |
|---|---|---|
| click | Triggered when a cell is clicked | event |
CellGroup Slots
| Name | Description |
|---|---|
| default | default slot |
| title | Custom group title |
Cell Slots
| Name | Description |
|---|---|
| title | Custom left title |
| value | Customize the right content |
| label | Custom description information below the title |
| icon | Customize the left icon |
| right-icon | Customize the right icon |
| extra | Customize the extra content on the rightmost side of the cell |
Theme customization
Style variables
The component provides the following CSS variables, which can be used to customize styles. For usage, please refer to ConfigProvider component.
| Name | Default | Description |
|---|---|---|
| --z-cell-font-size | var(--z-font-size-md) | - |
| --z-cell-line-height | 48rpx | - |
| --z-cell-vertical-padding | 20rpx | - |
| --z-cell-horizontal-padding | var(--z-padding-md) | - |
| --z-cell-text-color | var(--z-text-color) | - |
| --z-cell-background | var(--z-background-2) | - |
| --z-cell-border-color | var(--z-border-color) | - |
| --z-cell-active-color | var(--z-active-color) | - |
| --z-cell-required-color | var(--z-danger-color) | - |
| --z-cell-label-color | var(--z-text-color-2) | - |
| --z-cell-label-font-size | var(--z-font-size-sm) | - |
| --z-cell-label-line-height | var(--z-line-height-sm) | - |
| --z-cell-label-margin-top | var(--z-padding-base) | - |
| --z-cell-value-color | var(--z-text-color-2) | - |
| --z-cell-value-font-size | inherit | - |
| --z-cell-icon-size | 32rpx | - |
| --z-cell-right-icon-color | var(--z-gray-6) | - |
| --z-cell-large-vertical-padding | var(--z-padding-sm) | - |
| --z-cell-large-title-font-size | var(--z-font-size-lg) | - |
| --z-cell-large-label-font-size | var(--z-font-size-md) | - |
| --z-cell-large-value-font-size | inherit | - |
| --z-cell-group-background | var(--z-background-2) | - |
| --z-cell-group-title-color | var(--z-text-color-2) | - |
| --z-cell-group-title-padding | var(--z-padding-md) var(--z-padding-md) var(--z-padding-xs) | - |
| --z-cell-group-title-font-size | var(--z-font-size-md) | - |
| --z-cell-group-title-line-height | 32rpx | - |
| --z-cell-group-inset-padding | 0 var(--z-padding-md) | - |
| --z-cell-group-inset-radius | var(--z-radius-lg) | - |
| --z-cell-group-inset-title-padding | var(--z-padding-md) var(--z-padding-md) var(--z-padding-xs) var(--z-padding-xl) | - |
