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

ParametersDescriptionTypeDefault value
titleGroup titlestring-
insetWhether to display rounded card stylebooleanfalse
borderWhether to display the outer borderbooleantrue

Cell Props

ParametersDescriptionTypeDefault value
titleleft titlenumber | string-
valueRight contentnumber | string-
labelDescription information below the titlestring-
sizeCell size, optional values are large normalstring-
iconThe icon name or image link on the left, which is equivalent to the name attribute of the Icon componentstring-
icon-prefixIcon class name prefix, equivalent to the class-prefix attribute of the Icon componentstringz-icon
borderWhether to display the inner borderbooleantrue
clickableWhether to enable click feedbackbooleannull
is-linkWhether to display the right arrow and enable click feedbackbooleanfalse
requiredWhether to display the required asterisk in the formbooleanfalse
centerWhether to center the content verticallybooleanfalse
arrow-directionArrow direction, optional values are left up downstringright
title-styleAdditional style for left titlestring | Array | object-
title-classAdditional class name for left titlestring | Array | object-
value-classAdditional class name of the right contentstring | Array | object-
label-classDescription information additional class namestring | Array | object-

Cell Events

Event nameDescriptionCallback parameters
clickTriggered when a cell is clickedevent

CellGroup Slots

NameDescription
defaultdefault slot
titleCustom group title

Cell Slots

NameDescription
titleCustom left title
valueCustomize the right content
labelCustom description information below the title
iconCustomize the left icon
right-iconCustomize the right icon
extraCustomize 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.

NameDefaultDescription
--z-cell-font-sizevar(--z-font-size-md)-
--z-cell-line-height48rpx-
--z-cell-vertical-padding20rpx-
--z-cell-horizontal-paddingvar(--z-padding-md)-
--z-cell-text-colorvar(--z-text-color)-
--z-cell-backgroundvar(--z-background-2)-
--z-cell-border-colorvar(--z-border-color)-
--z-cell-active-colorvar(--z-active-color)-
--z-cell-required-colorvar(--z-danger-color)-
--z-cell-label-colorvar(--z-text-color-2)-
--z-cell-label-font-sizevar(--z-font-size-sm)-
--z-cell-label-line-heightvar(--z-line-height-sm)-
--z-cell-label-margin-topvar(--z-padding-base)-
--z-cell-value-colorvar(--z-text-color-2)-
--z-cell-value-font-sizeinherit-
--z-cell-icon-size32rpx-
--z-cell-right-icon-colorvar(--z-gray-6)-
--z-cell-large-vertical-paddingvar(--z-padding-sm)-
--z-cell-large-title-font-sizevar(--z-font-size-lg)-
--z-cell-large-label-font-sizevar(--z-font-size-md)-
--z-cell-large-value-font-sizeinherit-
--z-cell-group-backgroundvar(--z-background-2)-
--z-cell-group-title-colorvar(--z-text-color-2)-
--z-cell-group-title-paddingvar(--z-padding-md) var(--z-padding-md) var(--z-padding-xs)-
--z-cell-group-title-font-sizevar(--z-font-size-md)-
--z-cell-group-title-line-height32rpx-
--z-cell-group-inset-padding0 var(--z-padding-md)-
--z-cell-group-inset-radiusvar(--z-radius-lg)-
--z-cell-group-inset-title-paddingvar(--z-padding-md) var(--z-padding-md) var(--z-padding-xs) var(--z-padding-xl)-