Skip to content

Divider 分割线

区隔不同内容区域、段落标题或操作按钮组的细线条组件,支持嵌入文本/图标、虚线样式、渐隐渐变、垂直分割以及自定义色彩。


代码示例

1. 基础分割线 (Basic)

默认水平实线居中分隔。

vue
<template>
  <p>段落一:木智宇 UI 专注极奢黑白熊猫风格设计。</p>
  <mu-divider />
  <p>段落二:全面支持小程序、H5 与 App 多端自适应。</p>
</template>

2. 嵌入文案与矢量图标 (Text & Icon)

通过 content 属性或默认插槽嵌入文案,也可配合 icon 传入 Lucide 矢量图标。

vue
<template>
  <mu-divider content="暂无更多数据" />
  <mu-divider icon="sparkles" content="AI 智能推荐" />
  <mu-divider icon="heart" content="猜你喜欢" />
</template>

3. 文案对齐位置 (Orientation)

通过 orientation(或 contentPosition)设置文字的对齐位置,可选 left(靠左)、center(居中)、right(靠右)。

vue
<template>
  <mu-divider content="靠左对齐" orientation="left" />
  <mu-divider content="居中对齐" orientation="center" />
  <mu-divider content="靠右对齐" orientation="right" />
</template>

4. 虚线与渐隐渐变风格 (Variants)

设置 dashed 开启虚线线条;设置 variant="gradient" 开启向两侧渐隐的极奢淡化线条。

vue
<template>
  <!-- 虚线模式 -->
  <mu-divider dashed content="虚线分割线 Dashed" />

  <!-- 渐隐渐变模式 -->
  <mu-divider variant="gradient" content="渐隐渐变 Gradient" />
</template>

5. 垂直分割线 (Vertical)

设置 vertical 属性开启垂直方向分隔线,常用于导航链接、文本按钮组之间的分隔。

vue
<template>
  <div class="action-bar">
    <span>登录</span>
    <mu-divider vertical />
    <span>注册</span>
    <mu-divider vertical />
    <span>忘记密码</span>
    <mu-divider vertical dashed />
    <span>在线客服</span>
  </div>
</template>

6. 自定义色彩 (Custom Color)

使用 color 属性自定义分割线条颜色,使用 textColor 自定义中间文案颜色。

vue
<template>
  <mu-divider color="#3B82F6" textColor="#3B82F6" content="蓝色品牌分割" />
  <mu-divider color="#10B981" textColor="#10B981" icon="check" content="已加载完毕" />
</template>

API 属性说明 (Props)

参数名说明类型可选值默认值
content嵌入的说明文案String-''
orientation文案对齐位置 (同 contentPosition)Stringleft | center | right'center'
contentPosition文案对齐位置 (别名属性)Stringleft | center | right''
dashed是否为虚线样式Booleantrue | falsefalse
variant线条渲染风格Stringsolid | dashed | gradient'solid'
vertical是否为垂直分割线Booleantrue | falsefalse
color分割线线条颜色String-''
textColor中间文案颜色String-''
icon中间嵌入的矢量图标名称String-''
margin自定义外边距 (如 '30rpx 0')String-''

插槽说明 (Slots)

插槽名说明
default自定义分割线中间包裹的内容 (覆盖 content 属性)

基于 MIT 协议开源发行

H5 模拟器 (divider)☀️🔄