Separator
SaveA horizontal or vertical divider line on Base UI Separator, with an optional label at the start, middle, or end.
- Category
- Feedback
- Version
- 0.1.0
- Frameworks
- Next.js, Vite + React
- Styling
- Tailwind CSS v4
Preview
Separator preview
Continue with GitHub
or
name@company.com
Deployed main to production
Yesterday
Rolled back preview build 1842
DocsChangelogv2.4.1
Installation
npx @shakenui/cli add separatorReview the plan first. A dry run lists every file and package without changing anything:
npx @shakenui/cli add separator --dry-runUsage
separator-example.tsx
import { Separator } from "@/components/shaken/ui/separator";
const field = "flex h-9 items-center rounded-lg border border-zinc-950/12 px-3 text-sm dark:border-white/15";
export default function SeparatorExample() {
return (
<div className="grid w-full max-w-md gap-8">
<div className="grid gap-3 rounded-xl border border-zinc-950/10 p-5 dark:border-white/10">
<div className={`${field} justify-center font-medium text-zinc-950 dark:text-white`}>Continue with GitHub</div>
<Separator label="or" />
<div className={`${field} text-zinc-500`}>name@company.com</div>
</div>
<div className="grid gap-3 text-sm">
<p className="text-zinc-950 dark:text-white">Deployed main to production</p>
<Separator label="Yesterday" labelPosition="start" variant="dotted" />
<p className="text-zinc-950 dark:text-white">Rolled back preview build 1842</p>
</div>
<div className="flex h-5 items-center gap-3 text-sm text-zinc-600 dark:text-zinc-400">
<span>Docs</span>
<Separator orientation="vertical" />
<span>Changelog</span>
<Separator orientation="vertical" />
<span className="font-mono text-xs tabular-nums">v2.4.1</span>
</div>
</div>
);
}API
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | Horizontal spans the width; vertical stretches to the height of its flex row. |
| label | ReactNode | — | Text or an icon drawn in a gap in the line, such as "or" or a date. |
| labelPosition | "start" | "center" | "end" | "center" | Where the label sits along the line. |
| strength | "divider" | "hairline" | "divider" | divider is the quiet line used inside containers; hairline matches container borders. |
| variant | "solid" | "dashed" | "dotted" | "solid" | Line style. |
| decorative | boolean | false | Sets role="none" for lines that are purely visual, so screen readers skip them. |
Accessibility
- Renders role="separator" with aria-orientation through Base UI Separator.
- A string label also becomes the separator's aria-label, so it is announced once.
- decorative switches the role to none for lines that only add visual rhythm.
- Not focusable and has no motion.
Files
Installed into src/components/shaken, or components/shaken when the project has no src directory.
src/components/shaken/ui/separator.tsxseparator- npm packages: @base-ui/react@^1.9.0React and Tailwind CSS v4 required
Source
The exact source the CLI installs, from /r/items/react/separator/0.1.0.json.
ui/separator.tsxShowHide
ui/separator.tsx
"use client";
import { Separator as BaseSeparator } from "@base-ui/react/separator";
import type { ReactNode } from "react";
function cx(...classes: (string | false | null | undefined)[]) {
return classes.filter(Boolean).join(" ");
}
// `divider` is the quiet line inside containers; `hairline` matches container borders.
// Dashed and dotted lines are mostly gaps, so they draw a step stronger to read at the same weight.
const strengths = {
divider: {
solid: "border-zinc-950/[0.07] dark:border-white/[0.08]",
broken: "border-zinc-950/15 dark:border-white/[0.18]",
},
hairline: {
solid: "border-zinc-950/10 dark:border-white/12",
broken: "border-zinc-950/20 dark:border-white/25",
},
} as const;
const styles = {
solid: "border-solid",
dashed: "border-dashed",
dotted: "border-dotted",
} as const;
export interface SeparatorProps extends Omit<BaseSeparator.Props, "className" | "children"> {
className?: string;
/** `horizontal` spans the width; `vertical` stretches to the height of a flex row. */
orientation?: "horizontal" | "vertical";
/** Text or an icon in the middle of the line, such as "or" or a date. */
label?: ReactNode;
/** Where the label sits along the line. */
labelPosition?: "start" | "center" | "end";
/** `divider` (default) for inside containers, `hairline` to match a container border. */
strength?: keyof typeof strengths;
/** Line style. Dotted echoes the dot language of the agent marks. */
variant?: keyof typeof styles;
/**
* Purely visual lines (inside a menu row, between toolbar icons that are already grouped)
* can opt out of the separator role so screen readers skip them.
*/
decorative?: boolean;
}
/**
* A horizontal or vertical line that divides content, with an optional label in the middle.
* Without a label it is a Base UI Separator (`role="separator"` and `aria-orientation`).
*/
export function Separator({
orientation = "horizontal",
label,
labelPosition = "center",
strength = "divider",
variant = "solid",
decorative = false,
className,
...props
}: SeparatorProps) {
const vertical = orientation === "vertical";
const tone = strengths[strength][variant === "solid" ? "solid" : "broken"];
const line = cx(
tone,
styles[variant],
vertical ? "w-0 self-stretch border-l" : "h-0 w-full border-t",
);
// Only override Base UI's role="separator" when asked; passing role={undefined} would erase it.
const roleProps = decorative ? { role: "none" } : {};
if (label == null || label === false) {
return (
<BaseSeparator
orientation={orientation}
{...roleProps}
className={cx("shrink-0", line, vertical && "min-h-4", className)}
{...props}
/>
);
}
// With a label the lines are drawn on each side. A string label also names the separator,
// so a screen reader hears it once (separator children are presentational).
const segment = cx("flex-1", tone, styles[variant], vertical ? "w-0 border-l" : "h-0 border-t");
return (
<BaseSeparator
orientation={orientation}
{...roleProps}
aria-label={typeof label === "string" && !decorative ? label : undefined}
className={cx(
"flex shrink-0 items-center",
vertical ? "min-h-16 flex-col gap-2 self-stretch" : "w-full gap-3",
className,
)}
{...props}
>
<span aria-hidden="true" className={cx(segment, labelPosition === "start" && (vertical ? "max-h-3" : "max-w-4"))} />
<span
className={cx(
"inline-flex shrink-0 items-center gap-1.5 text-xs leading-4 font-medium whitespace-nowrap text-zinc-500 [&_svg]:size-3.5",
vertical && "[writing-mode:horizontal-tb]",
)}
>
{label}
</span>
<span aria-hidden="true" className={cx(segment, labelPosition === "end" && (vertical ? "max-h-3" : "max-w-4"))} />
</BaseSeparator>
);
}