Separator
A hairline that divides content horizontally or vertically, with an optional label and a decorative mode for purely visual lines.
HextaUI
Components that feel great to use and to write.
pnpm dlx shadcn@latest add https://hextaui.com/r/separator.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react cnCopy and paste the following code into your project.
components/ui/separator.tsx Update the import paths to match your project setup.
The line is one physical pixel thick on every screen, the same hairline as borders, so it lines up with cards and inputs around it. Space it with the parent's gap or a margin.
Vertical
With orientation="vertical" the line stretches to the height of its flex row. Outside a flex row, give it a height.
Label
Children sit in the middle of the line, with the line filling the space on both sides.
Align
align moves the label to the start or end, which suits section and date headers. Icons are sized to the text.
Vertical label
A vertical separator with a label keeps the text upright and draws the line above and below it.
Decorative
decorative hides a purely visual line from screen readers, so they don't announce a separator between rows that already read well on their own.
Inline
Use render to output a <span> where a <div> isn't allowed, like inside a paragraph.
Ada Park4 min read
Long content
Long labels wrap and unbroken strings break, while a short stretch of line stays visible on each side.
Right to left
Start and end follow the reading direction.
- A plain separator has
role="separator"andaria-orientation, like an<hr>. - With
decorative, it getsrole="none"and screen readers skip it. - A separator with a label has no role. The separator role would make its text presentational, so the label is read as plain text instead.
Built on the Base UI Separator. Renders a <div> and accepts its attributes.
| Prop | Type | Default |
|---|---|---|
orientation | "horizontal" | "vertical" | "horizontal" |
decorativeHide the line from screen readers when it is only visual. | boolean | false |
childrenA label drawn in the line. Leave it out for a plain line. | ReactNode | – |
alignWhere the label sits along the line. | "start" | "center" | "end" | "center" |
className | string | (state) => string | – |
render | ReactElement | (props, state) => ReactElement | <div> |
| Attribute | Description |
|---|---|
data-slot="separator" | Target separators in CSS. |
data-orientation | "horizontal" or "vertical". |
data-content | Present when the separator has a label. |
data-align | The label's alignment, when there is a label. |
data-slot="separator-label" | The element that wraps the label. |