Skip to content

Divider 分割线 ​

介绍 ​

用于将内容分隔为多个区域。

基础用法 ​

默认渲染一条水平分割线。

html
<vd-divider />

展示文本 ​

通过默认插槽在分割线中间插入内容。

html
<vd-divider>文本</vd-divider>

内容位置 ​

通过 content-position 指定内容所在位置。

html
<vd-divider content-position="left">文本</vd-divider>
<vd-divider content-position="right">文本</vd-divider>

虚线 ​

添加 dashed 属性使分割线渲染为虚线。

html
<vd-divider dashed>文本</vd-divider>

自定义样式 ​

可通过 color、custom-style 设置颜色与样式。

html
<vd-divider color="#1989fa">文本</vd-divider>
<vd-divider :custom-style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }">
  文本
</vd-divider>

垂直 ​

html
文本
<vd-divider vertical />
文本
<vd-divider vertical dashed />
文本
<vd-divider vertical :hairline="false" />
文本

API ​

Props ​

参数说明类型默认值
content-position内容位置'left' | 'center' | 'right''center'
dashed是否使用虚线booleanfalse
hairline是否使用 0.5px 线booleantrue
vertical是否使用垂直分割线booleanfalse
color自定义颜色(同时作用于文字与线条)string-

代替原始 Props ​

参数说明类型默认值
custom-id根节点idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Slots ​

名称说明
default内容(垂直模式不展示)

类型定义 ​

组件导出以下类型定义:

ts
import type {
  DividerProps,
  DividerContentPosition,
  DividerThemeVars,
} from 'vital-design';

样式变量 ​

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件。

名称默认值描述
--vd-divider-theme-marginvar(--vd-padding-md) 0水平外边距
--vd-divider-theme-vertical-margin0 var(--vd-padding-xs)垂直外边距
--vd-divider-theme-colorvar(--vd-color-text-2)文字颜色
--vd-divider-theme-font-sizevar(--vd-font-size-md)字号
--vd-divider-theme-line-height24px行高
--vd-divider-theme-border-colorvar(--vd-color-border)线条颜色
--vd-divider-theme-content-paddingvar(--vd-padding-md)内容两侧间距
--vd-divider-theme-content-left-width10%左对齐时左侧线宽
--vd-divider-theme-content-right-width10%右对齐时右侧线宽

赣ICP备2025061025号-1