Divider 分割线

用于分隔内容的分割线组件

<template>
  <div class="flex flex-col gap-4 p-4">
    <SkDivider />
    <SkDivider />
  </div>
</template>

用法

Text 文本

Prop类型默认值描述
textstring | number-通过属性快速设置文本内容
也可以通过 默认插槽 default 自定义任意内容(图标、徽标或更复杂的节点)
<template>
  <div class="flex flex-col gap-4 p-4">
    <SkDivider text="今日推荐" />
    <SkDivider>
      <div class="flex items-center gap-2 text-secondary text-body-small">
        <SkIcon name="i-lucide:sparkles" size="32rpx" />
        <span>自定义插槽</span>
      </div>
    </SkDivider>
  </div>
</template>

Content Position 文本位置

Prop类型默认值描述
contentPosition"start" | "center" | "end"center控制文本相对整条横向分割线的位置
<template>
  <div class="flex flex-col gap-4 p-4">
    <SkDivider text="左对齐" content-position="start" />
    <SkDivider text="居中" content-position="center" />
    <SkDivider text="右对齐" content-position="end" />
  </div>
</template>

Dashed 虚线

Prop类型默认值描述
dashedbooleanfalse是否渲染为虚线
<template>
  <div class="flex flex-col gap-4 p-4">
    <SkDivider text="虚线分割" dashed />
    <SkDivider dashed />
  </div>
</template>

Color 颜色

Prop类型默认值描述
colorstring-设置线条和默认文本的颜色
textColorstring-仅覆盖文本颜色,优先级高于 color
<template>
  <div class="flex flex-col gap-4 p-4">
    <SkDivider text="品牌色" color="#4D80F0" />
    <SkDivider text="自定义文字颜色" color="#FF6B6B" text-color="#FFB347" />
    <SkDivider text="粗线条" :hairline="false" thickness="4px" />
  </div>
</template>

Thickness 粗细

Prop类型默认值描述
thicknessstring | number1px调整线条粗细,支持数值或任意 CSS 单位
若需要完全按照 thickness 控制粗细,请先将 hairline 设置为 false
<template>
  <div class="flex flex-col gap-4 p-4">
    <SkDivider text="默认 1px" />
    <SkDivider text="2px" :thickness="2" />
    <SkDivider text="4px" thickness="4px" />
  </div>
</template>

Hairline 发丝线

Prop类型默认值描述
hairlinebooleantrue是否启用 1px 发丝线(细线)样式
<template>
  <div class="flex flex-col gap-4 p-4">
    <SkDivider text="默认发丝线" />
    <SkDivider text="关闭发丝线" :hairline="false" />
    <SkDivider text="自定义粗细" :hairline="false" thickness="4px" />
  </div>
</template>

Orientation 方向

Prop类型默认值描述
orientation"horizontal" | "vertical"horizontal选择横向或纵向分割线
lengthstring | number-纵向分割线高度(可选)
<template>
  <div class="flex items-center justify-center gap-6 p-4 text-body-medium">
    <span>上午</span>
    <SkDivider orientation="vertical" length="64px" />
    <span>下午</span>
    <SkDivider orientation="vertical" dashed :thickness="2" length="48px" />
    <span>晚上</span>
  </div>
</template>

Props 总览

Prop描述
text设置文本内容,优先级低于插槽
color控制线条和默认文本颜色
textColor单独覆盖文本颜色
orientation横向或纵向分割线
contentPosition控制横向文本位置
dashed是否渲染为虚线
hairline是否启用 1px 发丝线样式,关闭后可配合 thickness
thickness控制线条粗细(关闭发丝线后生效)
length纵向分割线高度
clax传入 @skiyee/ucv 生成的额外类名

Slots

Slot描述
default自定义文案或内容
Copyright © sKy(skiyee) 2025-present