Separator

A thin dividing line that visually separates content horizontally or vertically. It is built on Base UI's Separator primitive and styled with the shared border color token.

Separator
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme detection failed · neutral
See how it was built

Installation

pnpm dlx shadcn@latest add @retroui/separator

Requires @retroui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Separator } from "@/components/ui/separator"export function Example() {  return (    <div>      <p>Section one</p>      <Separator />      <p>Section two</p>    </div>  )}
  • Separating sections of a page, card, or form with a subtle horizontal rule
  • Dividing items in a toolbar, button group, or navigation bar with a vertical line
  • Splitting a menu or dropdown into logical groups
  • Adding visual rhythm between list items or settings rows without adding a heavy border

Examples

Horizontal divider between sections

A full-width horizontal separator dividing two stacked text blocks inside a card.

horizontal-divider-between-sections.tsx
import { Separator } from "@/components/ui/separator"export function ProfileCard() {  return (    <div className="w-72 space-y-3 p-4">      <div>        <h3 className="font-semibold">Account</h3>        <p className="text-sm text-muted-foreground">Manage your profile details.</p>      </div>      <Separator />      <div>        <h3 className="font-semibold">Billing</h3>        <p className="text-sm text-muted-foreground">View invoices and payment methods.</p>      </div>    </div>  )}

Vertical separator in a toolbar

A vertical separator placed between groups of inline actions. It stretches to match the row height because the component applies self-stretch in vertical mode.

vertical-separator-in-a-toolbar.tsx
import { Separator } from "@/components/ui/separator"export function Toolbar() {  return (    <div className="flex h-9 items-center gap-2">      <button type="button">Bold</button>      <button type="button">Italic</button>      <Separator orientation="vertical" />      <button type="button">Link</button>      <button type="button">Image</button>    </div>  )}

Menu with grouped items

Separators split a list of menu actions into logical groups while keeping the default horizontal orientation.

menu-with-grouped-items.tsx
import { Separator } from "@/components/ui/separator"export function ContextMenu() {  return (    <div className="w-48 rounded-md border p-1">      <button type="button" className="block w-full text-left">Cut</button>      <button type="button" className="block w-full text-left">Copy</button>      <Separator className="my-1" />      <button type="button" className="block w-full text-left">Rename</button>      <button type="button" className="block w-full text-left">Delete</button>    </div>  )}

Custom spacing with className

Pass a className to adjust margins around the separator; the component merges it with its base classes via cn().

custom-spacing-with-classname.tsx
import { Separator } from "@/components/ui/separator"export function SettingsRow() {  return (    <section className="space-y-2">      <p>Notifications</p>      <Separator className="my-4 bg-foreground" />      <p>Privacy</p>    </section>  )}

API reference

PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Direction of the line. Horizontal renders a 1px-high full-width rule; vertical renders a 1px-wide line that stretches to the parent height.
classNamestring—Additional classes merged with the base styles (shrink-0, bg-border, and orientation sizing) via cn().
...propsSeparatorPrimitive.Props (from @base-ui/react/separator)—All other props of the Base UI Separator are forwarded to the underlying element. The data-slot attribute is set to "separator" by the component.

Accessibility

  • Base UI's Separator renders with role="separator" and aria-orientation matching the orientation prop, so assistive technologies announce it as a divider.
  • Separators are purely decorative when used only for visual grouping; avoid relying on them alone to convey meaning.
  • Because the line has no text, ensure surrounding content has clear headings or labels so screen reader users can understand section boundaries.
  • Color contrast of bg-border against the background is subtle; do not use it as the only indicator of a boundary where contrast requirements apply.
  • Pass a className that changes color with care to keep sufficient contrast for users with low vision.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Separator" component (retroui/separator) from its shadcn registry.1. Install it with: npx shadcn@latest add @retroui/separator2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: orientation, className, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Separator } from "@/components/ui/separator"export function Example() {  return (    <div>      <p>Section one</p>      <Separator />      <p>Section two</p>    </div>  )}```

Files & dependencies

  • separator.tsx→ components/ui/separator.tsx
dependencies@base-ui/react

Looks similar, elsewhere