shadcn.io is not affiliated with official shadcn/ui
Separator examples · Spacing
With Margins Separator for React
A horizontal separator with vertical margins on the line itself instead of a parent gap.
Let the line own its pause. This React Separator carries my-6 itself, in a plain block container with no gap, so the spacing stays attached to the line when the siblings don't share one flex rhythm. Use it when a separator sits between mixed content that shouldn't inherit a common gap.
Preview
Installation
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.
Related
- Tight Spacing SeparatorA horizontal separator in a flex column
- Default Spacing SeparatorA horizontal separator in a flex column
- Wide Spacing SeparatorA horizontal separator in a flex column
- Inset SeparatorA horizontal separator inset from both
- Horizontal SeparatorA horizontal separator that divides a
- Section Divider SeparatorA horizontal separator between two titled