Separator
Visually or semantically separates content.
When to Use
Use Separator when you need to:
- Visually divide sections of content within a page or container
- Create horizontal rules between stacked blocks of text or cards
- Separate inline items such as navigation links or toolbar actions
- Provide semantic grouping boundaries for assistive technology
- Add visual rhythm and whitespace to dense layouts
When Not to Use
- Between list items that already have distinct borders - use border styling on the list items instead
- To create complex multi-pane layouts - use Resizable panels
- As a decorative border around content - use Card with built-in borders
- For spacing only - use margin or padding utilities instead of a visual line
Default
Combined horizontal and vertical separators in a typical content layout.
Radix Primitives
An open-source UI component library.
Horizontal
Horizontal separators between stacked content sections. This is the default orientation.
Section One
Content above separator
Section Two
Content below separator
Section Three
More content below
Vertical
Vertical separators between inline items. Requires a parent with explicit height and flex alignment.
UX & Design Guidelines
Visual Hierarchy
Separators create visual breaks that help users scan and group related content. Use them sparingly to avoid visual clutter. A single bg-border separator is subtle enough for most use cases. Reserve thicker or colored separators (e.g., bg-primary) for major section boundaries.
Spacing & Layout
Add consistent spacing around separators using my-4 or my-6 for horizontal separators. For vertical separators, wrap items in a flex items-center container with space-x-4 for uniform gaps. Vertical separators need an explicit parent height (e.g., h-5).
Responsive Behavior
Horizontal separators scale naturally to full container width. Vertical separators may need to switch to horizontal on smaller screens. Use responsive classes like hidden md:block to conditionally show vertical separators. Consider replacing separator-divided inline layouts with stacked layouts on mobile.
Color & Contrast
The separator uses the bg-border semantic token, which adapts to light and dark modes automatically. Avoid hardcoding colors; instead use semantic tokens like bg-muted or bg-primary for alternative separator styles. Ensure sufficient contrast against the background for visibility.
Accessibility
Keyboard Navigation
- Tab -- Separators are not focusable and do not appear in the tab order
- Arrow Keys -- No keyboard interaction; separators are non-interactive elements
- When used in toolbars, separators group adjacent controls without interrupting keyboard flow
Screen Reader Support
- Decorative separators (
decorative=true) are hidden from assistive technology entirely - Semantic separators (
decorative=false) exposerole="separator" - Screen readers announce semantic separators as content boundaries
- The
aria-orientationattribute is set automatically based on theorientationprop
Decorative vs Semantic
By default, separators are decorative (decorative=true) and use role="none", making them invisible to screen readers. Set decorative=false when the separator conveys a meaningful content boundary, such as separating distinct sections in a form or toolbar. Use decorative separators for purely visual spacing.
WAI-ARIA Compliance
Built on @radix-ui/react-separator, which follows the WAI-ARIA separator role specification. Semantic separators receive role="separator" and the correct aria-orientation value. Decorative separators use role="none" to be fully transparent to assistive technology.
ARIA Attributes
{/* Default decorative separator - no ARIA role */}
<Separator />
{/* Semantic separator - gets role="separator" */}
<Separator decorative={false} />
{/* Vertical semantic separator with orientation */}
<Separator
orientation="vertical"
decorative={false}
/>
{/* Separator in a toolbar context */}
<div role="toolbar" aria-label="Formatting options">
<button>Bold</button>
<button>Italic</button>
<Separator orientation="vertical" decorative={false} />
<button>Left align</button>
<button>Center</button>
</div>Related Components
Resizable
Accessible resizable panel groups and layouts with draggable dividers.
Card
Container with header, content, and footer sections separated by borders.
Aspect Ratio
Displays content within a desired ratio for consistent layout proportions.
Accordion
Vertically stacked sections with built-in separators between items.
API Reference
The Separator component accepts the following props in addition to standard HTML div attributes.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | The direction of the separator line. Horizontal creates a full-width line; vertical creates a full-height line. |
| decorative | boolean | true | When true, the separator is purely visual and hidden from assistive technology. Set to false for semantic separators. |
| className | string | — | Additional CSS classes to apply to the separator. |
| data-slot | string | "separator" | Data attribute for styling and selection. Automatically set. |