shadcn.io is not affiliated with official shadcn/ui
Separator examples · Styled
Dashed Separator for React
A dashed horizontal separator drawn with a top border on a transparent line.
Soften a hard rule. This React Separator drops its fill with bg-transparent, draws a dashed top border and sets its own height to zero, so the border is the only stroke. Use it for optional sections, draft blocks and informal groupings.
Preview
Installation
FAQ
When should I use a dashed separator?
For informal or optional boundaries: draft content, suggested groupings, secondary breaks. Keep a solid line for the structural sections of a page.
Why border-dashed instead of a background?
A background can't be dashed. The example clears the fill with bg-transparent, adds border-t border-dashed and sets the line's height to zero, so you don't get a one-pixel box plus a one-pixel border.
The height uses the component's orientation variant, data-horizontal:h-0, so it replaces the default.
Can I control dash length?
Not with border-dashed: the browser draws the pattern. Use an SVG or a repeating gradient background if you need a custom dash.
How do I change the dash color?
With border color utilities such as border-primary or border-muted-foreground/40: the color lives on the border, not the background.
Related
- Dotted SeparatorA dotted horizontal separator drawn with
- Horizontal SeparatorA horizontal separator that divides a
- Thick SeparatorA 4 pixel horizontal separator for major
- Gradient SeparatorA horizontal separator that fades in and
- Standard CardA basic card with a title, a description
- Section Divider SeparatorA horizontal separator between two titled