Separator
A hairline that divides content horizontally or vertically, with an optional label and a decorative mode for purely visual lines.
- Layout components
- 1 parts
- 9 examples
@base-ui/react
See it in a real product: Discount Builder, Order Detail, Order Status, and 4 more
View blockHextaUI
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.
With orientation="vertical" the line stretches to the height of its flex row. Outside a flex row, give it a height.
Children sit in the middle of the line, with the line filling the space on both sides.
align moves the label to the start or end, which suits section and date headers. Icons are sized to the text.
A vertical separator with a label keeps the text upright and draws the line above and below it.
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.
Use render to output a <span> where a <div> isn't allowed, like inside a paragraph.
Long labels wrap and unbroken strings break, while a short stretch of line stays visible on each side.
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. |
- AccordionStacked headings that each reveal a panel, with height motion you can reverse mid-way and panels that stay searchable while closed.
- Aspect ratioA box that holds its shape before media loads, shimmers while loading, fades the media in and falls back when it fails.
- CarouselNative scroll-snap slides with momentum on touch, mouse dragging, arrow keys, dots, thumbnails and an autoplay that pauses when it should.
- CollapsibleA panel that shows and hides with height motion you can reverse mid-way, without jumping the layout.
- ResizablePanels you can drag apart, with a quiet divider that wakes up on hover, sizes that glide on reset or collapse, and layouts that persist.
- Scroll areaNative scrolling with a minimal scrollbar, edges that fade only where there’s more to see, and an optional peek that cuts the last item in half.
Used in Pro blocks
Blocks that build on Separator.
Every block comes with HextaUI Pro, and Prompt Input is free.