生态产品多个设计器现已发布正式版

查看生态总览
跳转到内容

Separator 分隔线 ​

分隔相关内容或内容分组。

用法 ​

分隔内容区域

账户设置

管理个人资料与登录方式。

通知设置

选择需要接收的消息。

组件结构 ​

加粗的是必需部件。

data-scope="separator":root · line · content

示例 ​

垂直分隔线 ​

分隔行内内容

概览分析报告

分组标题 ​

在分隔线中显示标题

变体 ​

设置分隔线强度和线型

默认弱化强调虚线

设计指引 ​

何时使用 ​

  • 分隔菜单、列表、工具栏或表单区域。
  • 在分隔线中显示分组标题。

何时不用 ​

  • 只需留白时使用间距。
  • 每项都需要分隔时优先调整列表结构。

特性 ​

  • 支持水平和垂直方向。
  • 支持默认、弱化、强调和虚线样式。
  • 支持居中或靠边的分组标题。
  • decorative 可将纯视觉分隔线移出无障碍树。
  • 分节文字照标准结构排成线、文字、线三段,三端出自同一个结构函数:Vue / React 的 XhSeparator 给了插槽内容即是这样;Web Components 不写部件(或只写 root)时,宿主直接子节点写 slot="content" 就生成这三段,什么都不给即是一条线。

组合 ​

最佳实践 ​

  • 纯视觉分隔线使用 decorative。
  • 垂直分隔线的父容器应有明确高度。

反模式 ​

  • 不要用分隔线替代语义标题。
  • 不要在同一区域堆叠过多分隔线。

API 参考 ​

产物 ​

层值
自定义元素<xh-separator>
Vue 组件XhSeparator XhSeparatorContent XhSeparatorLine XhSeparatorRoot
状态机无,connect 直接由 props 算属性
皮肤@xihan-ui/styles/separator.css

Props ​

属性类型必填说明
alignSeparatorAlign分节文字的位置,默认居中;默认档不输出 data-align。
dashedboolean绘制为虚线;实线段与空白段的长度使用 --xh-separator-dash-length / -dash-gap 两个槽。
decorativeboolean装饰性分隔:仅视觉分组,root 通过 role=none + aria-hidden 完整退出无障碍树。
orientation'horizontal' | 'vertical'
variantSeparatorVariant线的绘制方式,默认 default;默认档不输出 data-variant。

connect API ​

getXxxProps() 返回对应部件的宿主属性。

成员类型说明
getRootProps() => T['element']
getLineProps() => T['element']
getContentProps() => T['element']

无障碍 ​

键盘 ​

规格出处:W3C APG

无键盘交互(不接收焦点,或焦点行为完全由原生元素提供)。

ARIA ​

以下属性由 connect 生成。

部件属性值
rootaria-hidden'true' | undefined
rootaria-orientation'vertical' | undefined
rootrole'none' | 'separator'
linerole'none'

样式参考 ​

皮肤 ​

@xihan-ui/styles/separator.css 按 [data-scope="separator"][data-part="root"] 部件选择器书写,发布产物以挂载类 .xh-scope-separator 代替其中的 data-scope(特异性相同),位于 xihan.components 层。覆盖样式使用 xihan.overrides,部件选择器照常可用。

forced-colors: active 下另有一套规则:颜色交给系统,边框与状态标记改用系统色关键字。

数据属性 ​

由 connect 生成;条件不成立时不输出无值属性。

部件属性值
rootdata-alignprops.align
rootdata-dashed''(条件成立时才出现)
rootdata-orientationprops.orientation
rootdata-variantprops.variant
linedata-orientationprops.orientation

CSS 变量 ​

本组件公开覆盖槽由独立皮肤的实际消费位生成;默认来源、作用部件和状态均与 CSS 同源。

变量部件CSS 属性状态默认来源说明
--xh-separator-align-lengthline
root
flexalign=end
align=start
first-child
last-child
--xh-space-6separator 的 line、root 部件 flex 覆盖槽。
--xh-separator-colorline
root
backgrounddashed
default
orientation=horizontal
orientation=vertical
variant=strong
variant=subtle
--xh-border-default
--xh-border-strong
--xh-material-soft-separator
separator 的 line、root 部件 background 覆盖槽。
--xh-separator-content-fgcontentcolordefault--xh-fg-defaultseparator 的 content 部件 color 覆盖槽。
--xh-separator-content-font-sizecontentfont-sizedefault--xh-text-body-sizeseparator 的 content 部件 font-size 覆盖槽。
--xh-separator-content-font-weightcontentfont-weightdefault--xh-font-weight-mediumseparator 的 content 部件 font-weight 覆盖槽。
--xh-separator-dash-gapline
root
backgrounddashed
orientation=horizontal
orientation=vertical
--xh-space-1_5separator 的 line、root 部件 background 覆盖槽。
--xh-separator-dash-lengthline
root
backgrounddashed
orientation=horizontal
orientation=vertical
--xh-space-1_5separator 的 line、root 部件 background 覆盖槽。
--xh-separator-gaprootgaphas([data-part='content'])--xh-space-4separator 的 root 部件 gap 覆盖槽。
--xh-separator-mxrootmargin-inlineorientation=vertical--xh-space-3separator 的 root 部件 margin-inline 覆盖槽。
--xh-separator-myrootmargin-blockhas([data-part='content'])
orientation=horizontal
--xh-space-2_5
--xh-space-5
separator 的 root 部件 margin-block 覆盖槽。
--xh-separator-radiusline
root
border-radiusdefault--xh-shape-pillseparator 的 line、root 部件 border-radius 覆盖槽。
--xh-separator-thicknessline
root
block-size
inline-size
orientation=horizontal
orientation=vertical
--xh-stroke-thinseparator 的 line、root 部件 block-size、inline-size 覆盖槽。

动效 ​

本组件皮肤不含过渡与关键帧,也没有脚本驱动的动效:状态一变,外观立即到位。

RTL ​

皮肤用逻辑属性排布(inline-start 一族),dir="rtl" 下自动镜像。

Released under The MIT License