Divider
SM, under 950B gzippedA horizontal or vertical rule, with an optional inline label.
- Category
- Media & layout
- Budget
- sm, single-purpose control
- Runtime deps
- None
Preview
or
This is the exact fixture the conformance suite renders in CI. Switch the language to see the component mirror and reformat.
Install
npx shadcn@latest add https://kata-ui-rho.vercel.app/r/divider.jsonCopies the source into your project. Pulls in 1 primitive: cn.
Source
import { cn } from "../lib/cn";
export interface DividerProps {
orientation?: "horizontal" | "vertical";
/** Optional label, e.g. "or". Splits the rule into two segments around it. */
label?: string;
className?: string;
}
/**
* A semantic rule, horizontal or vertical, with an optional inline label.
*
* Uses `role="separator"` rather than a bare `<hr>` when labelled, since a
* label turns it into a compound element `<hr>` cannot express; margins use
* logical properties so a vertical divider's spacing does not need mirroring
* by hand in RTL layouts.
*/
export function Divider({ orientation = "horizontal", label, className }: DividerProps) {
if (orientation === "vertical") {
return (
<div
role="separator"
aria-orientation="vertical"
className={cn("mx-2 inline-block h-full w-px self-stretch bg-neutral-200 dark:bg-neutral-800", className)}
/>
);
}
if (!label) {
return <hr className={cn("border-neutral-200 dark:border-neutral-800", className)} />;
}
return (
<div
role="separator"
aria-orientation="horizontal"
className={cn("flex items-center gap-3 text-sm text-neutral-500 dark:text-neutral-400", className)}
>
<span className="h-px flex-1 bg-neutral-200 dark:bg-neutral-800" />
<span>{label}</span>
<span className="h-px flex-1 bg-neutral-200 dark:bg-neutral-800" />
</div>
);
}
What CI checks
- Bundled, minified and gzipped against its tier budget
- Audited by axe in the state previewed above
- Rendered through react-dom/server with no browser globals
- Scanned for network calls, dangerous sinks, and unguarded animation