Separator
Semantic horizontal or vertical divider. Renders as hr with role=separator.
Examples
List
Horizontal separators between list items.
- Item 1
- Value 1
- Item 2
- Value 2
- Item 3
- Value 3
import { Separator } from "@codefast/ui/separator";
export function SeparatorList() {
return (
<div className="flex w-full max-w-sm flex-col gap-2 text-sm">
<dl className="flex items-center justify-between">
<dt>Item 1</dt>
<dd className="text-muted-foreground">Value 1</dd>
</dl>
<Separator />
<dl className="flex items-center justify-between">
<dt>Item 2</dt>
<dd className="text-muted-foreground">Value 2</dd>
</dl>
<Separator />
<dl className="flex items-center justify-between">
<dt>Item 3</dt>
<dd className="text-muted-foreground">Value 3</dd>
</dl>
</div>
);
}
RTL
Right-to-left layout support for languages such as Arabic and Hebrew.
Translations are AI-generated for demonstration and may be imperfect.
import { Separator } from "@codefast/ui/separator";
import type { Translations } from "#/features/components-catalog/components/detail/language";
import { useTranslation } from "#/features/components-catalog/components/detail/language-context";
const translations: Translations = {
en: {
dir: "ltr",
values: {
title: "codefast/ui",
subtitle: "The Foundation for your Design System",
description: "A set of beautifully designed components that you can customize, extend, and build on.",
},
},
ar: {
dir: "rtl",
values: {
title: "codefast/ui",
subtitle: "الأساس لنظام التصميم الخاص بك",
description: "مجموعة من المكونات المصممة بشكل جميل يمكنك تخصيصها وتوسيعها والبناء عليها.",
},
},
he: {
dir: "rtl",
values: {
title: "codefast/ui",
subtitle: "הבסיס למערכת העיצוב שלך",
description: "סט של רכיבים מעוצבים בצורה יפה שאתה יכול להתאים אישית, להרחיב ולבנות עליהם.",
},
},
};
export function SeparatorRtl() {
const { dir, t } = useTranslation(translations, "ar");
return (
<div className="flex max-w-sm flex-col gap-4 text-sm" dir={dir}>
<div className="flex flex-col gap-1.5">
<div className="leading-none font-medium">{t.title}</div>
<div className="text-muted-foreground">{t.subtitle}</div>
</div>
<Separator />
<div>{t.description}</div>
</div>
);
}
Vertical
Use orientation='vertical' for a vertical separator.
import { Separator } from "@codefast/ui/separator";
export function SeparatorVertical() {
return (
<div className="flex h-5 items-center gap-4 text-sm">
<div>Blog</div>
<Separator orientation="vertical" />
<div>Docs</div>
<Separator orientation="vertical" />
<div>Source</div>
</div>
);
}
Usage
The minimal import and composition — see Examples below for styled, real-world variants.
import { Separator } from "@codefast/ui/separator";
export function SeparatorUsage() {
return (
<div>
<p className="text-sm">Above the line</p>
<Separator className="my-4" />
<p className="text-sm">Below the line</p>
</div>
);
}
Anatomy
How the parts nest — every slot the component exposes, in composition order.
Features
- decorative defaults to true (hidden from assistive tech) — set it to false when the divider carries real document structure that should be announced.
- align positions a SeparatorItem (e.g. an "OR" label) centered on the rule.
API reference
Props for each part of the component. All native element props are also forwarded.
Separator
A semantic divider.
orientation"horizontal" | "vertical"Direction of the rule. Give vertical separators a height.
Default
"horizontal"decorativebooleanWhen true, it’s hidden from assistive tech (purely visual).
Default
true
Accessibility
Built to be keyboard-navigable and screen-reader friendly out of the box.
- Decorative by default — no role, hidden from assistive tech. Set decorative={false} to expose role=separator when the divider carries real structure.
- Give vertical separators an explicit height (e.g. h-3).
Guidelines
Conventions that keep usage consistent across an app.
Do
- Use to group and separate related sections.
- Keep separators subtle — they organise, not decorate.
Don’t
- Don’t overuse separators where spacing alone would do.
- Don’t forget a height on vertical separators, or they won’t show.
Explore further
Ready to integrate?
Follow the Getting Started guide to install @codefast/ui, or browse the full component gallery.