Skip to content

xtf-divider

组件说明

xtf-divider 是分割线组件,用于分隔内容区域。支持水平/垂直方向、文字/图标内容、多种主题色、线条类型(实线/虚线/点线)、对齐方式和发光效果,适用于列表分隔、区域划分和表单分组等场景。


基础用法

1. 水平分割线

默认为水平实线分割线:

vue
<template>
  <view>
    <xtf-text level="body" text="上方内容" />
    <xtf-divider />
    <xtf-text level="body" text="下方内容" />
  </view>
</template>

2. 带文字的分割线

通过 text 设置分割线文字:

vue
<template>
  <view>
    <xtf-text level="body" text="账号登录" />
    <xtf-divider text="其他方式" />
    <xtf-button label="微信登录" block />
  </view>
</template>

3. 带图标的分割线

通过 icon 设置图标,通过 iconPosition 设置图标位置:

vue
<template>
  <view>
    <xtf-divider icon="star" text="精选推荐" theme="warning" />
    <xtf-divider icon="arrow_down" icon-position="end" text="展开更多" theme="info" />
  </view>
</template>

4. 主题与样式

通过 theme 切换主题色,通过 type 切换线条类型:

vue
<template>
  <view style="display: flex; flex-direction: column; gap: 24rpx">
    <xtf-divider text="主要" theme="primary" />
    <xtf-divider text="成功" theme="success" />
    <xtf-divider text="警告" theme="warning" />
    <xtf-divider text="危险" theme="danger" />
    <xtf-divider text="虚线" type="dashed" />
    <xtf-divider text="点线" type="dotted" />
    <xtf-divider text="渐隐" type="fade" />
    <xtf-divider text="渐变" type="gradient" />
    <xtf-divider text="发光" type="glow" />
    <xtf-divider text="双线" type="double" />
  </view>
</template>

5. 垂直分割线

通过 vertical 启用垂直模式:

vue
<template>
  <view style="display: flex; align-items: center; gap: 16rpx">
    <xtf-text level="body" text="选项A" />
    <xtf-divider vertical />
    <xtf-text level="body" text="选项B" />
    <xtf-divider vertical />
    <xtf-text level="body" text="选项C" />
  </view>
</template>

全部属性

属性类型默认值作用描述适用范围
textString''分割线文字文字内容
iconString''图标名称图标
iconPositionString'start'图标位置:'start' / 'end'图标位置
themeString'primary'主题色:'primary' / 'success' / 'warning' / 'danger' / 'info' / 'inverse'主题
colorString''自定义线条颜色自定义颜色
textColorString''自定义文字颜色文字颜色
backgroundString''自定义背景色背景色
borderColorString''自定义边框色边框色
glowColorString''自定义发光色发光效果
typeString'solid'线条类型:'solid' / 'dashed' / 'dotted' / 'fade' / 'gradient' / 'glow' / 'double'线条样式
contentVariantString'plain'内容变体内容样式
alignString'center'对齐方式:'left' / 'center' / 'right'对齐
verticalBooleanfalse是否垂直方向方向
insetString | Number0两侧缩进(rpx)缩进
lengthString | Number''自定义长度长度
thicknessString | Number'2rpx'线条粗细粗细
contentPaddingString | Number'4rpx 10rpx'内容区域内边距内边距
customClassString''自定义类名样式覆盖
customStyleString | Object | Array''自定义样式动态样式覆盖

事件

无自定义事件。


插槽

插槽名称说明
default替换中间文字内容
icon替换起始图标
icon-end替换结束图标

插槽使用示例

vue
<template>
  <xtf-divider content-variant="chip" theme="success">
    <template #icon><xtf-icon name="check_circle" theme="success" size="xs" /></template>
    <xtf-text text="已完成" color="success" />
    <template #icon-end><xtf-icon name="verified" theme="success" size="xs" /></template>
  </xtf-divider>
</template>

主题说明

  • 线条颜色跟随 theme 属性,使用对应的 CSS 变量(如 var(--xtf-color-primary)
  • 文字颜色跟随主题色
  • 发光效果使用对应主题色的半透明色
  • 支持 6 种主题:primary / success / warning / danger / info / inverse

如需全局调整主题,请在 xtf-config-provider 或主题配置中覆盖相关 CSS 变量。

MIT Licensed