A semantic or decorative divider with horizontal, vertical, and centered-label layouts.
Keep track of the latest changes.
Your team approved the new layout.
import { Separator } from "@/components/ballmac/separator"
export default function SeparatorDemo() {
return (
<div className="w-full max-w-sm rounded-xl border bg-card p-5 shadow-sm">
<div className="text-sm font-semibold">Project activity</div>
<p className="mt-1 text-xs text-muted-foreground">
Keep track of the latest changes.
</p>
<Separator label="Today" className="my-5" />
<div className="text-sm">Design review completed</div>
<p className="mt-1 text-xs text-muted-foreground">
Your team approved the new layout.
</p>
</div>
)
}Installation
$ pnpm dlx shadcn@latest add @ballmac/separatorInstall the dependencies.
$ pnpm add radix-uiCopy the source into your project.
components/ballmac/separator.tsx// Ballmac UI: Separator. https://ui.ballmac.com/components/separator // Based on shadcn/ui Separator (MIT, Copyright (c) 2023 shadcn), adding an optional centered label. import * as React from "react" import { Separator as SeparatorPrimitive } from "radix-ui" import { cn } from "@/lib/utils" type SeparatorProps = React.ComponentProps<typeof SeparatorPrimitive.Root> & { /** Short text displayed in the middle of a horizontal separator. */ label?: string } function Separator({ className, orientation = "horizontal", decorative = true, label, ...props }: SeparatorProps) { if (label && orientation === "horizontal") return ( <div data-slot="separator-labeled" role={decorative ? "presentation" : "separator"} className={cn( "text-muted-foreground flex w-full items-center gap-3 text-xs", className, )} {...props} > <span aria-hidden="true" className="bg-border h-px min-w-0 flex-1" /> <span>{label}</span> <span aria-hidden="true" className="bg-border h-px min-w-0 flex-1" /> </div> ) return ( <SeparatorPrimitive.Root data-slot="separator" decorative={decorative} orientation={orientation} className={cn( "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px", className, )} {...props} /> ) } export { Separator, type SeparatorProps }Update the import paths to match your project setup.
Usage
import { Separator } from "@/components/ballmac/separator"The full example is in the Code tab above.
Examples
States and variants
import { Separator } from "@/components/ballmac/separator"
export default function SeparatorStates() {
return (
<div className="flex w-full max-w-sm items-center gap-4 rounded-xl border bg-card p-5 text-sm">
<span>Overview</span>
<Separator orientation="vertical" className="h-5" />
<span>Activity</span>
<Separator orientation="vertical" className="h-5" />
<span>Settings</span>
</div>
)
}API reference
| Prop | Type | Default |
|---|---|---|
labelShort text displayed in the middle of a horizontal separator. | string | — |
Also accepts the standard attributes of its root element.
Use with AI
A semantic or decorative divider with horizontal, vertical, and centered-label layouts. With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI Separator (@ballmac/separator) to this project with the shadcn MCP, then use it where it fits.
Use it for
- Separate groups of related content
- Divide a form with a short label
Not for
- Use spacing alone when separation is already clear
Registry JSON: https://ui.ballmac.com/r/separator.json
Credits
Based on shadcn/ui Separator, adapted by Ballmac. Free to use in personal and commercial projects.
- npm
- radix-ui
- Registry
- shadcn/utils
Pairs well with
Card
A composable content surface with compact spacing, an action slot, and optional interactive feedback.
App Shell
The frame of an application page: skip link, sticky header, sidebar that becomes a sheet on small screens, main area, optional aside and footer.
Aspect Ratio
A CSS-native ratio frame that reserves space for media and safely handles invalid ratio values.
Bento Grid
A responsive bento layout of feature cards that span columns and rows. Each BentoCard has a background visual slot, icon, title and description, and a link that slides up on hover or focus.