Basic · Divider

Divider

Divider is a linear, lightweight component used to logically organize element content and page structure or areas.

Demos

How to import

<script lang="ts">
    import { Divider } from '@fibrae/semi-ui-svelte';
</script>

Basic Usage

水平实线

Semi Design 是一个设计系统。 它定义了一套中后台设计与前端基础组件。

水平虚线

Semi Design 是一个设计系统。 它定义了一套中后台设计与前端基础组件。

垂直实线

左 中 右

垂直虚线

左 中 右
Code
<script lang="ts">
    import { Divider } from '@fibrae/semi-ui-svelte';
</script>

<div>
    <h3>水平实线</h3>
    <span>Semi Design 是一个设计系统。</span>
    <Divider margin="12px" />
    <span>它定义了一套中后台设计与前端基础组件。</span>

    <h3 style="margin-top: 40px">水平虚线</h3>
    <span>Semi Design 是一个设计系统。</span>
    <Divider dashed margin="12px" />
    <span>它定义了一套中后台设计与前端基础组件。</span>

    <h3 style="margin-top: 40px">垂直实线</h3>

    <div>
        <span>左</span>
        <Divider layout="vertical" margin="12px" />
        <span>中</span>
        <Divider layout="vertical" margin="12px" />
        <span>右</span>
    </div>

    <h3 style="margin-top: 40px">垂直虚线</h3>
    <div>
        <span>左</span>
        <Divider dashed layout="vertical" margin="12px" />
        <span>中</span>
        <Divider dashed layout="vertical" margin="12px" />
        <span>右</span>
    </div>
</div>

With Children

The content of a horizontal divider is written inside the tag (children); a vertical divider shows no content. For a horizontal divider with content, the content is always wrapped in semi-divider_inner-text, whether it is plain text or an element.

这是居左文字
这是居中文字
这是居右文字
Code
<script lang="ts">
    import { IconSemiLogo } from '@fibrae/semi-icons-svelte';
    import { Divider } from '@fibrae/semi-ui-svelte';
</script>

<div>
    <Divider align="left" margin="12px">这是居左文字</Divider>

    <Divider align="center" margin="12px">这是居中文字</Divider>

    <Divider align="right" margin="12px">这是居右文字</Divider>

    <Divider margin="12px">
        <IconSemiLogo />
    </Divider>
</div>

API Reference

Props

PropertyDescriptionTypeDefault
alignAlignment of the content: left, center or right.'left' | 'right' | 'center'"center"
childrenContent of a horizontal divider. A vertical divider shows no content.Snippet-
dashedWhether the line is dashed.boolean-
layoutDirection of the divider: horizontal or vertical.'horizontal' | 'vertical'"horizontal"
marginMargin above and below the divider, or left and right when vertical. A number is in pixels.number | string-

class, style and other native attributes land on the root element; style comes after margin, so your value wins. The default role is separator, which is not set when the divider has content; a role you pass overrides the default.

Design Tokens

These are the component's internal Sass variables and cannot be overridden. To customize styles, override the --semi-* CSS variables (see the Design Token page) or write unlayered CSS rules.
Sass variableValueUsage
$spacing-divider_horizontal-marginLeft0px水平模式左间距
$spacing-divider_horizontal-marginRight0px水平模式右间距
$spacing-divider_horizontal-marginTop1px水平模式上间距
$spacing-divider_horizontal-marginBottom1px水平模式下间距
$spacing-divider_vertical-marginLeft1px垂直模式左间距
$spacing-divider_vertical-marginRight1px垂直模式右间距
$spacing-divider_vertical-marginTop0px垂直模式上间距
$spacing-divider_vertical-marginBottom0px垂直模式下间距
$spacing-divider_inner_text-paddingLeft8px内容为纯文字时内容左间距
$spacing-divider_inner_text-paddingRight8px内容为纯文字时内容右间距
$spacing-divider_inner_text-paddingTop0px内容为纯文字时内容上间距
$spacing-divider_inner_text-paddingBottom0px内容为纯文字时内容下间距
$width-divider_inner_text_left_line40px左对齐文字时左间距宽度
$width-divider_inner_text_right_line40px右对齐文字时右间距宽度
$width-divider-border1px分割线宽度
$height-divider_vertical20px垂直分割线高度
$color-divider_border-colorvar(--semi-color-border)分割线颜色
$color-divider_text-defaultvar(--semi-color-text-0)标题颜色
$font-divider_text-weight$font-weight-bold分割线文字字重