Divider
Separate paragraphs or items within a row.
Import
import { HuiDivider } from '@nscode/handy-ui'
Basic Usage
The default divider is a horizontal 1px line in the theme's border color, with 16px of space above and below.
<template>
<p>First paragraph</p>
<HuiDivider />
<p>Second paragraph</p>
</template>
With Text
Content in the default slot appears within the line. Set content-position to left, center (the default), or right. A divider aligned to either side leaves a 16px line on that side.
<template>
<HuiDivider content-position="left">Left (left)</HuiDivider>
<HuiDivider>Center (center)</HuiDivider>
<HuiDivider content-position="right">Right (right)</HuiDivider>
</template>
The slot also accepts elements such as icons and tags:
<template>
<HuiDivider><HuiIcon name="star" /></HuiDivider>
<HuiDivider content-position="left">
<HuiSpace size="small">
<HuiIcon name="calendar" />
<span>November 2026</span>
</HuiSpace>
</HuiDivider>
<HuiDivider content-position="right"
><HuiTag type="success" size="small">Completed</HuiTag></HuiDivider
>
</template>
Line Styles
Set border-style to solid (the default), dashed, or dotted. Each style works with or without text, at any content position.
<template>
<HuiDivider>Solid (solid)</HuiDivider>
<HuiDivider border-style="dashed">Dashed (dashed)</HuiDivider>
<HuiDivider border-style="dotted">Dotted (dotted)</HuiDivider>
<HuiDivider border-style="dashed" />
<HuiDivider border-style="dotted" />
<HuiDivider border-style="dashed" content-position="left">Dashed, left</HuiDivider>
<HuiDivider border-style="dotted" content-position="right">Dotted, right</HuiDivider>
</template>
Vertical Dividers
Use direction="vertical" to separate items in a row. A vertical divider leaves 8px of space on each side.
<template>
<p style="margin-bottom: 12px">
Edit<HuiDivider direction="vertical" />Copy<HuiDivider direction="vertical" />Delete
</p>
<div style="display: flex; align-items: center; height: 40px">
<span>Toolbar</span>
<HuiDivider direction="vertical" />
<span>Stretch to the row height</span>
</div>
</template>
Vertical dividers support all three line styles:
<script setup lang="ts">
import { HuiDivider, HuiSpace } from '@nscode/handy-ui'
import type { DividerBorderStyle } from '@nscode/handy-ui'
const borderStyles: DividerBorderStyle[] = ['solid', 'dashed', 'dotted']
</script>
<template>
<HuiSpace direction="vertical" align="start">
<div v-for="item in borderStyles" :key="item">
<span class="row-label">{{ item }}</span>
<span>Edit</span>
<HuiDivider direction="vertical" :border-style="item" />
<span>Copy</span>
<HuiDivider direction="vertical" :border-style="item" />
<span>Delete</span>
</div>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 56px;
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
}
</style>
A vertical divider can also contain text, with 12px of space above and below it. The two line segments share the remaining height equally. Inside a flex container with a defined height, the divider stretches to the container's height:
<template>
<div class="login">
<div class="login__item">Sign in with a password</div>
<HuiDivider direction="vertical">or</HuiDivider>
<div class="login__item">Scan to sign in</div>
</div>
</template>
<style scoped>
.login {
display: flex;
height: 160px;
padding: var(--hui-spacing-4) 0;
box-sizing: border-box;
}
.login__item {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
}
</style>
Ancestor Variable Overrides
Set --hui-divider-border-style on the component or any ancestor to override the line style of horizontal and vertical dividers. Without this variable, the border-style prop provides the solid/dashed/dotted default. The public variable takes precedence; the prop only determines the private default. Nested dividers inherit the ancestor's public configuration.
<script setup lang="ts">
import { HuiDivider, HuiSpace } from '@nscode/handy-ui'
</script>
<template>
<HuiSpace
class="divider-variables-demo"
direction="vertical"
fill
style="--hui-divider-border-style: double"
>
<span>An ancestor sets double, overriding all three prop defaults in both directions.</span>
<HuiDivider border-style="solid">solid default</HuiDivider>
<HuiDivider border-style="dashed">dashed default</HuiDivider>
<HuiDivider border-style="dotted">dotted default</HuiDivider>
<HuiSpace style="height: 48px"
><span>Left</span><HuiDivider direction="vertical" /><span>Right</span></HuiSpace
>
</HuiSpace>
</template>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| direction | 'horizontal' | 'vertical' | 'horizontal' | Direction |
| contentPosition | 'left' | 'center' | 'right' | 'center' | Content position |
| borderStyle | 'solid' | 'dashed' | 'dotted' | 'solid' | Line style |
Slots
| Slot | Description |
|---|---|
| default | Text or content shown within the line |
Types
import type { DividerProps } from '@nscode/handy-ui'