Separator
FreeDivide groups of content with a thin line, horizontal or vertical, solid or dashed.
npx wunderui-cli add separatorPlayground
Workspace
WunderUI · info@wunderui.com
Members, billing and security.
Workspace
WunderUI · info@wunderui.com
Members, billing and security.
Installation
npx wunderui-cli add separatorWrites the source into your project with its dependencies and, on first use, the styles - see Installation.
Then import what you need:
import { Separator } from "@/components/ui/separator"Then use it:
import { Separator } from "@/components/ui/separator"
export function Workspace() {
return (
<div className="w-80 text-sm">
<p className="font-medium text-foreground">Workspace</p>
<Separator className="my-4" />
<p className="text-text-secondary">Members, billing and security.</p>
</div>
)
}Expected result: You see a line of text, a 1 px line across the full 320 px width with 16 px of space above and below it, and a second line of text.
When to use
Use Separator for
- Dividing groups of content inside one surface, such as two sections of a card or the rows of a list
- Setting inline items apart in a row, such as links, figures or toolbar groups
- A lighter dashed break inside one section, such as the line above a total
Use something else for
- Divider with Label for a line with a word, a button or an icon on it, such as or between two ways to sign in
- Toolbar for a row of actions, which has its own ToolbarSeparator for splitting groups
- Card for a group that deserves its own surface instead of a line around it
Orientation
A horizontal line is 1 px high and fills the width of its container. A vertical line is 1 px wide and stretches to the height of its row, so the row needs a height.
Workspace
WunderUI · info@wunderui.com
Members, billing and security.
Style
Solid is the line between sections. Dashed is a lighter break inside one section, such as the line above a total.
Team plan
3 seats, billed monthly
Payment method
Visa ending in 4242
Semantics
Screen readers announce a separator by default. When headings or the list already show the boundary, make it decorative by setting role and aria-hidden yourself.
Notifications
Choose what reaches your inbox.
Security
Two-factor authentication and sessions.
Notifications
Choose what reaches your inbox.
Security
Two-factor authentication and sessions.
Spacing in layouts
The line has no margin of its own. Use a vertical margin of 16 px between sections, row padding between list rows, and 8 px on each side in a toolbar.
Workspace
WunderUI · info@wunderui.com
Members, billing and security.
Nora Lindgren
Daniel Okafor
Priya Raman
Behavior and motion
What the separator does with length, style, semantics and motion.
- Length
- A horizontal separator is 1 px high and full width, a vertical one 1 px wide and as tall as its flex row, so put it in a row with a height. It never collapses.
- Style
- Solid fills the line with the border colour. Dashed draws a 1 px dashed border in the same colour, on the top for horizontal and the left for vertical.
- Semantics
- Base UI renders a div with the separator role and sets the orientation. Horizontal is the default and vertical is announced as such, and the line is not focusable.
- Decorative
- There is no decorative prop. Pass a presentation role and aria-hidden to remove the line from the accessibility tree, as Divider with Label does.
- Spacing
- The separator has no margin. Use a vertical margin between stacked blocks, padding on list rows and a gap in a row, so one rule sets the air for every line.
- Theme
- The colour is the border token in both styles, so the line follows the theme and dark mode with no extra class.
- Motion
- The separator has no state and no transition. Nothing in it moves.
- Reduced motion
- There is no animation to reduce, so reduced motion changes nothing.
Anatomy
The Separator is one element. The figure marks the line between two groups of text, and the vertical one is the same part turned on its side.
Workspace
WunderUI · info@wunderui.com
Members, billing and security.
- 1data-slot="separator"
A 1 px line, horizontal by default and as wide as its container, or vertical and as tall as its row. It can be dashed, never shrinks in a flex row and has no margin.
Best practices
- Do
Place a vertical Separator in a flex row that has a height. It stretches to the row, so without one the line has nothing to stretch to.
- Do
Use the dashed style for a lighter break inside one section, such as the line above a total, and the solid line between sections.
- Do
Leave the spacing to the layout: a vertical margin between sections, padding on list rows, and a gap in a row.
- Do
Make the line decorative when a heading, list or group already shows the boundary. Keep the default when the line is the only sign of it.
- Don’t
Don't draw dividers with a border class or a hex colour. Separator uses the border token, so it follows the theme and dark mode.
- Don’t
Don't use a Separator as a panel resizer, because it is not focusable and has no value. A resizable layout needs a splitter with keyboard support.
- Don’t
Don't stack a Separator on a border that is already there, such as the last row of a bordered list or a card edge. Two lines read as one thick one.
API reference
One table for the one part. Separator also takes every prop of the Base UI separator and of the div it renders, such as id, role and aria-hidden.
A 1 px line, horizontal by default and as wide as its container, or vertical and as tall as its row. It can be dashed, never shrinks in a flex row and has no margin.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | runs across the container and is the default. runs down a flex row and stretches to its height. It also sets . |
| dashed | boolean | false | Draws the line as a 1 px dashed border instead of a filled line, for a lighter break inside one section. |
| render | ReactElement | (props, state) => ReactElement | — | Replaces the with another element or component, for example . The role and the orientation attribute are still set on it. |
| className | string | (state) => string | undefined | — | Extra classes for the line, such as a margin () or a fixed length for a vertical line (). A function receives the state and returns the classes. |
| style | CSSProperties | (state) => CSSProperties | undefined | — | Inline styles for the line. A function receives the state, which holds the orientation, and returns the styles. |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("separator")npx wunderui-cli add separatorThe full library index for assistants is at /llms.txt.