Separator 分隔线
新粗野主义风格的视觉分隔线,支持水平和垂直方向。
预览
Preview
水平分隔线
上方内容
下方内容
垂直分隔线
左侧中间右侧
变体
尺寸
文字分隔线
章节标题
主色标题
安装
pnpm dlx brutx-vue@latest add separator用法
vue
<script setup>
import { Separator } from 'brutx-ui-vue'
</script>
<template>
<div>
<p class="text-sm font-medium">Content above</p>
<Separator />
<p class="text-sm font-medium">Content below</p>
</div>
</template>方向
水平(默认):
vue
<template>
<Separator orientation="horizontal" />
</template>垂直:
vue
<template>
<div class="flex h-8 items-center gap-4">
<span class="text-sm font-bold">Item 1</span>
<Separator orientation="vertical" />
<span class="text-sm font-bold">Item 2</span>
</div>
</template>文字分隔线
当 orientation="horizontal" 且默认插槽有实际内容时,Separator 会渲染为居中文字分隔线:两侧为分隔线,中间为插槽内容。
vue
<template>
<Separator>章节标题</Separator>
</template>文字分隔线同样支持 variant 与 size:
vue
<template>
<Separator variant="primary" size="lg">主色标题</Separator>
</template>注意:文字分隔线模式下,
class属性会应用到两侧的分隔线上,而非外层容器。这与普通模式下class应用到分隔线元素上的行为保持一致。
变体
| 变体 | 说明 |
|---|---|
default | 前景色(bg-brutal-fg) |
primary | 主色(bg-brutal-primary) |
muted | 静音色(bg-brutal-muted) |
vue
<template>
<div class="space-y-2">
<Separator variant="default" />
<Separator variant="primary" />
<Separator variant="muted" />
</div>
</template>尺寸
| 尺寸 | 粗细 |
|---|---|
sm | 2px |
default | var(--brutal-border-width, 3px) |
lg | 5px |
vue
<template>
<div class="space-y-2">
<Separator size="sm" />
<Separator size="default" />
<Separator size="lg" />
</div>
</template>API 参考
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
variant | "default" | "muted" | "primary" | undefined | "default" | 选择分隔线的颜色样式。 |
详情声明类型NonNullable<"default" | "primary" | "muted" | null | undefined> | undefined 字面量
默认值详情
来源packages/ui/src/components/separator/Separator.vue | |||
size | "default" | "lg" | "sm" | undefined | "default" | 控制分隔线的粗细预设。 |
详情声明类型NonNullable<"default" | "lg" | "sm" | null | undefined> | undefined 字面量
默认值详情
来源packages/ui/src/components/separator/Separator.vue | |||
orientation | "horizontal" | "vertical" | undefined | "horizontal" | 选择水平或垂直方向;文字内容仅在水平方向居中显示在线段之间。 |
详情声明类型NonNullable<"vertical" | "horizontal" | null | undefined> | undefined 字面量
默认值详情
来源packages/ui/src/components/separator/Separator.vue | |||
decorative | boolean | undefined | true | 设为装饰元素时不暴露分隔线语义;关闭后设置 role="separator" 及方向语义。 |
详情声明类型boolean | undefined 字面量
默认值详情
来源packages/ui/src/components/separator/Separator.vue | |||
class | string | undefined | undefined | 追加到原生分隔线或文字分隔线的线段元素。 |
详情声明类型string | undefined 默认值详情
来源packages/ui/src/components/separator/Separator.vue | |||
| 名称 | 签名或类型 | 说明 |
|---|---|---|
#default | {} | 可选的分隔线内容;水平且插槽有内容时在线段间显示文字,否则作为内容传给底层 Reka UI 分隔线原语。 |
详情声明类型{}来源packages/ui/src/components/separator/Separator.vue | ||
可访问性
- ARIA 属性:
decorative为true时无语义角色;为false时自动设置role="separator"