Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

With Margins Separator for Svelte

A horizontal line between Account and Billing, with the vertical space on the line itself rather than the parent.

UI library: Ark UI

Account sits above a horizontal line, and Billing sits below it. The line carries its own vertical margin, and the parent does not add a gap.

Put the margin on the line when the neighbors do not share one spacing rhythm. A parent gap is simpler, and a Card is clearer, when they do. In Svelte, Ark UI leaves the gap to the parent.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Separator anatomy: horizontal, vertical

Usage

<div class="w-full max-w-sm"><p class="text-sm">Account</p><Separator class="my-6" /><p class="text-sm">Billing</p></div>

FAQ

When should I use margins instead of gap?

When the line sits between mixed siblings that shouldn't share one gap, or when only this break needs a different pause. Prefer a gap when every child belongs to the same stack.

How do I set top and bottom separately?

Use mt-8 mb-4 for an uneven pause: more above to close the previous section, less below to attach the next heading.

Do separator margins collapse?

In a block container like this one, yes: my-6 next to a heading with mt-4 gives 24 pixels, not 40. Inside a flex or grid container margins don't collapse, and they add to the gap.

Can I use negative margins?

Avoid them: negative margins overlap content and break at other type sizes. Adjust the positive value instead.

Should margins change by breakpoint?

my-4 lg:my-8 is reasonable when the desktop layout has more air. Stay on the same spacing scale as the rest of the page.

Can I combine vertical and horizontal margins?

Yes, but a horizontal inset needs a width override, as the Inset Separator example shows: the line is full width by default, so mx-8 alone overflows the parent.

API Reference

Separator

No extra props in this demo. The rest is on the Separator page.