Skip to content

LimeTag 标签组件

一个功能丰富的标签组件,用于标记和分类。支持多种形状、尺寸、颜色和风格变体,可用于标记状态、分类、提示等多种场景。组件提供了丰富的自定义选项,可以满足各种复杂的界面设计需求。

插件依赖:lime-sharedlime-style

文档链接

📚 组件详细文档请访问以下站点:

安装方法

  1. 在uni-app插件市场入口 中搜索并导入lime-tag
  2. 导入后可能需要重新编译项目
  3. 在页面中使用l-tag组件

注意🔔

本插件依赖的【lime-svg】是原生插件,如果购买(收费为6元)则需要自定义基座,才能使用, 若不需要删除即可

代码演示

标签主题

通过 type 属性控制标签颜色。

html
<l-tag type="primary">品牌色</l-tag>
<l-tag type="success">成功色</l-tag>
<l-tag type="warning">警告色</l-tag>
<l-tag type="danger">危险色</l-tag>
<l-tag>通用色</l-tag>

标签形状

通过 shape 属性控制标签形状。

html
<l-tag shape="square" type="primary">方形</l-tag>
<l-tag shape="round" type="success">圆角</l-tag>
<l-tag shape="mark" type="primary">半圆</l-tag>

标签变种

通过variant 属性控制标签图标。

html
<l-tag variant="light">高亮</l-tag>
<l-tag variant="light" type="primary">品牌</l-tag>
<l-tag variant="light" type="success">成功</l-tag>
<l-tag variant="light" type="warning">警告</l-tag>
<l-tag variant="light" type="danger">危险</l-tag>

<l-tag>深色</l-tag>
<l-tag type="primary">品牌</l-tag>
<l-tag type="success">成功</l-tag>
<l-tag type="warning">警告</l-tag>
<l-tag type="danger">危险</l-tag>

<l-tag variant="outline">描边</l-tag>
<l-tag variant="outline" type="primary">品牌</l-tag>
<l-tag variant="outline" type="success">成功</l-tag>
<l-tag variant="outline" type="warning">警告</l-tag>
<l-tag variant="outline" type="danger">危险</l-tag>

<l-tag variant="light-outline">光廓</l-tag>
<l-tag variant="light-outline" type="primary">品牌</l-tag>
<l-tag variant="light-outline" type="success">成功</l-tag>
<l-tag variant="light-outline" type="warning">警告</l-tag>
<l-tag variant="light-outline" type="danger">危险</l-tag>

标签图标

通过icon 属性控制标签图标。

html
<l-tag icon="face-retouching" type="primary">标签</l-tag>
<l-tag icon="filter-3" variant="light">标签</l-tag>
<l-tag icon="markup" variant="outline">标签</l-tag>

标签尺寸

通过 size 属性控制标签大小。

html
<l-tag size="mini" type="primary">细</l-tag>
<l-tag size="small" type="primary">小</l-tag>
<l-tag size="medium" type="primary">中</l-tag>
<l-tag size="large" type="warning">大</l-tag>
<l-tag size="extra-large" type="primary">加大</l-tag>

超长文本省略标签

通过max-width 属性,当内容超过时显示省略号。

html
<l-tag max-width="130px" variant="light">听说超长可以省略听说超长</l-tag>

自定义颜色

通过 color 属性设置标签颜色,。

html
<l-tag color="#7232dd" icon="face-retouching">标签</l-tag>
<l-tag color="linear-gradient(to right, rgb(255, 96, 52), rgb(238, 10, 36))" icon="filter-3">标签</l-tag>
<l-tag color="#7232dd" icon="markup" variant="outline">标签</l-tag>

可关标签

通过 closable 属性设置标签可关闭,通过 @close事件接收关闭事件。

html
<l-tag v-if="show1" @close="show1 = false" :closable="true" icon="face-retouching" type="primary">标签</l-tag>
<l-tag v-if="show2" @close="show2 = false" :closable="true" icon="filter-3" variant="light">标签</l-tag>
<l-tag v-if="show3" @close="show3 = false" :closable="true" icon="markup" variant="outline">标签</l-tag>

快速预览

导入插件后,可以直接使用以下标签查看演示效果:

html
<!-- 代码位于 uni_modules/lime-tag/components/lime-tag -->
<lime-tag />

插件标签说明

标签名说明
l-tag组件标签
lime-tag演示标签

Vue2使用说明

main.js中添加以下代码:

js
// vue2项目中使用
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)

详细配置请参考官方文档:Vue Composition API

API文档

Props 属性说明

属性名说明类型默认值
content标签内容string-
type标签类型,可选值为 default primary success warning dangerstringdefault
shape标签形状,可选值为 square round markstringsquare
size标签尺寸,可选值为 mini small medium large extra-largestringmedium
variant标签风格变体,可选值为 solid light outline light-outlinestringsolid
closable是否可关闭booleanfalse
disabled是否禁用booleanfalse
icon标签中的图标,iconstring-
prefix前缀string-
maxWidth标签最大宽度,超出后显示省略号string-
color自定义标签颜色string-
textColor自定义文字颜色string-
fontSize自定义文字大小string-
radius自定义圆角大小string-
padding自定义内边距string-

Events 事件

事件名说明回调参数
click点击标签时触发event: Event
close关闭标签时触发event: Event

Slots 插槽

名称说明
default标签内容
icon自定义图标

主题定制

组件提供了以下CSS变量,可用于自定义样式:

变量名称默认值描述
--tag-solid-text-colorwhite实心标签文字颜色
--tag-default-solid-text-colorwhite默认实心标签文字颜色
--tag-border-radius$border-radius-sm方形标签圆角大小
--tag-mark-border-radius$tag-round-border-radius标记型标签圆角大小
--tag-close-icon-color$text-color-3关闭图标颜色
--tag-default-color$gray-11默认标签颜色
--tag-default-light-color$gray-1默认浅色标签颜色
--tag-default-border-color$gray-5默认标签边框颜色
--tag-primary-color$primary-color主要标签颜色
--tag-primary-light-color$primary-color-1主要浅色标签颜色
--tag-success-color$success-color成功标签颜色
--tag-success-light-color$success-color-1成功浅色标签颜色
--tag-warning-color$warning-color警告标签颜色
--tag-warning-light-color$warning-color-1警告浅色标签颜色
--tag-danger-color$error-color危险标签颜色
--tag-danger-light-color$error-color-1危险浅色标签颜色
--tag-mini-padding-x4px迷你标签水平内边距
--tag-mini-padding-y0迷你标签垂直内边距
--tag-mini-font-size9px迷你标签字体大小
--tag-mini-icon-size10px迷你标签图标大小
--tag-mini-height15px迷你标签高度
--tag-small-padding-x6px小型标签水平内边距
--tag-small-padding-y0小型标签垂直内边距
--tag-small-font-size$font-size-xs小型标签字体大小
--tag-small-icon-size12px小型标签图标大小
--tag-small-height20px小型标签高度
--tag-medium-padding-x8px中型标签水平内边距
--tag-medium-padding-y0中型标签垂直内边距
--tag-medium-font-size$font-size-sm中型标签字体大小
--tag-medium-icon-size14px中型标签图标大小
--tag-medium-height24px中型标签高度
--tag-large-padding-x8px大型标签水平内边距
--tag-large-padding-y0大型标签垂直内边距
--tag-large-font-size$font-size大型标签字体大小
--tag-large-icon-size16px大型标签图标大小
--tag-large-height28px大型标签高度
--tag-extra-large-padding-x15px超大标签水平内边距
--tag-extra-large-padding-y0超大标签垂直内边距
--tag-extra-large-font-size$font-size超大标签字体大小
--tag-extra-large-icon-size16px超大标签图标大小
--tag-extra-large-height40px超大标签高度

支持与赞赏

如果你觉得本插件解决了你的问题,可以考虑支持作者:

支付宝赞助微信赞助

源代码

组件源码