JGuang

分割线

Divider · Astryx

交互预览
npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

分割线 · Divider

分割线用于布局场景。下面的官方示例展示原生用法与状态,属性名保持上游 API。

安装与前置条件

npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

需要 React 19+,按顺序导入基础 CSS 和主题,并设置 Theme Provider。参见开始使用。

示例与使用方式

  • 分割线 · 综合展示 1:首先体验这个示例,再查看代码理解组件的组合方式。
  • 分割线 · 交互示例 2:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。
  • 分割线 · 样式变化 / 样式 3:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。
  • 分割线 · 交互示例 4:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。

API 与上游详细参考

优先使用 0.7.1 官方中文说明;上游尚未提供中文的条目保留英文。属性名、类型及默认值保持原生 API,不把示例状态名称当成组件属性。

Divider

A visual separator that divides content into distinct sections. Use to create clear boundaries between groups of related content, or to demarcate interactive regions within a layout.

属性类型默认值说明
orientation'horizontal' | 'vertical''horizontal'分隔线的方向。
labelReactNode居中显示在分隔线上的可选标签。数字 0 会保留;null、布尔值和空字符串不渲染标签。
variant'subtle' | 'strong''subtle'分隔线的视觉粗细。
isFullBleedbooleanfalse通过负边距将分隔线延伸至容器边缘。
xstyleStyleXStyles用于布局自定义的 StyleX 样式(边距、定位、尺寸)。必须是 stylex.create() 的值,不能是 style={{}} 这样的内联样式对象。

使用建议

  • Use subtle dividers between related content sections and strong dividers for high-contrast boundaries.
  • Add a label to the divider when sections need a visible category heading.
  • 避免:Overuse dividers; rely on spacing and layout to separate content when possible.

主题 API

{
  "targets": [
    {
      "className": "astryx-divider",
      "visualProps": [
        "orientation",
        "variant"
      ]
    }
  ]
}

组件结构

  • Divider group: Separator group that arranges one or two rules around an optional label.
  • Rule: Painted line segment; a second segment renders when a label is present.
  • Label: Optional content displayed between two rule segments.