Skip to content
Nacre
Color palette
中文

Divider

stableDividerOpen in playground
Divider
Runs the real component in your browser.

A 1pt line in the border color that separates groups within one block of content; horizontal by default and filling the width, or vertical and filling the height. Separate blocks from each other with whitespace, not lines.

Status: stable · Components: Divider

import { Divider } from 'nacre'

Horizontal: the parent sets the width and the line fills it; the spacing above and below comes from the parent’s gap.

import { Text, View } from 'nsh'
import { Divider, TEXT_SIZE } from 'nacre'
export function DividerUsage() {
return (
<View class="w-[320px] max-w-full gap-3">
<Text class={`${TEXT_SIZE.small} text-foreground`}>Ongoing chats</Text>
<Divider testID="demo-divider-h" />
<Text class={`${TEXT_SIZE.small} text-foreground`}>Ended chats</Text>
</View>
)
}

vertical: separates two groups of actions in a toolbar; its height follows the parent row (which needs a definite height).

import { View } from 'nsh'
import { Divider, IconButton } from 'nacre'
export function DividerVertical() {
return (
<View class="h-7 flex-row items-center gap-2">
<IconButton icon="copy" size="sm" label="Copy" />
<IconButton icon="reply" size="sm" label="Quote reply" />
<Divider testID="demo-divider-v" vertical />
<IconButton icon="trash" size="sm" label="Revoke" />
</View>
)
}

Vertical lines separate the time, channel and agent in one row, splitting it into segments more clearly than “·”.

import { Text, View } from 'nsh'
import { Divider, TEXT_SIZE } from 'nacre'
export function DividerMeta() {
return (
<View class="h-4 flex-row items-center gap-2">
<Text class={`${TEXT_SIZE.caption} text-muted-foreground tabular-nums`}>11-22 14:05</Text>
<Divider vertical />
<Text class={`${TEXT_SIZE.caption} text-muted-foreground`}>Web</Text>
<Divider vertical />
<Text class={`${TEXT_SIZE.caption} text-muted-foreground`}>Chen Zhiyuan</Text>
</View>
)
}

A single line separates two groups of fields in one card; don’t draw lines between cards.

import { Text, View } from 'nsh'
import { Button, Card, Divider, SectionHeader, TEXT_SIZE } from 'nacre'
export function DividerInCard() {
return (
<Card size="sm">
<SectionHeader title="Customer info" action={<Button size="sm" variant="ghost">Edit</Button>} />
<View class="gap-1">
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Name: Lin Jiayi</Text>
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Accounts: HK stocks · US stocks</Text>
</View>
<Divider />
<View class="gap-1">
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Last visit: 11-22 14:05</Text>
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Agent: Chen Zhiyuan</Text>
</View>
</Card>
)
}
  • Purely decorative and not in the screen reader tree; convey what a group means with a heading or text.

Do

  • Group within one block of content
  • Two orientations: horizontal in lists, vertical in toolbars
  • Give a vertical line’s parent row a fixed height (such as h-6)

Don’t

  • Draw a line between every row (use row spacing or ListBox’s gaps)
  • Separate two cards or two areas with a line (use whitespace)
  • Write h-px bg-border yourself
Prop Type Default Description
vertical boolean —
class string —
testID string —

* required