Skip to content

Separator ​

A horizontal or vertical divider, with an optional centered label.

Installation ​

bash
npx bootcn add separator
bash
pnpm dlx bootcn add separator
bash
yarn dlx bootcn add separator
bash
bunx --bun bootcn add separator

The CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.

Usage ​

html
<hr class="bootcn-separator" />

<div class="d-flex align-items-center">
  <span>Docs</span>
  <div
    class="bootcn-separator bootcn-separator--vertical"
    role="separator"
    aria-orientation="vertical"
  ></div>
  <span>Blog</span>
</div>

<div class="bootcn-separator-label" role="separator" aria-label="or continue with">
  <span class="bootcn-separator-label__text" aria-hidden="true">or continue with</span>
</div>

A vertical separator stretches to the height of its flex container; give the container a height or let its content define it.

Customizing ​

VariableDefault
--bootcn-separator-spacing1rem (margin around it)
--bootcn-separator-colorvar(--bootcn-border-color)

Dependencies ​

  • Bootstrap 5.3+ CSS.
  • themes/tokens/tokens.css.

No JavaScript.

Accessibility ​

  • Purely decorative dividers can use <div class="bootcn-separator" aria-hidden="true"> instead of <hr>.
  • The labeled separator exposes its text through aria-label; the visible text is hidden from assistive technology to avoid reading it twice.

Source ​

The exact files the CLI installs (separator@1.0.0). View on GitHub · Report an issue

html
<p class="mb-0">Account</p>
<hr class="bootcn-separator" />
<p class="mb-0">Billing</p>

<div class="d-flex align-items-center mt-4" style="height: 1.5rem">
  <span>Docs</span>
  <div
    class="bootcn-separator bootcn-separator--vertical"
    role="separator"
    aria-orientation="vertical"
  ></div>
  <span>Blog</span>
  <div
    class="bootcn-separator bootcn-separator--vertical"
    role="separator"
    aria-orientation="vertical"
  ></div>
  <span>Source</span>
</div>

<div class="bootcn-separator-label mt-4" role="separator" aria-label="or continue with">
  <span class="bootcn-separator-label__text" aria-hidden="true">or continue with</span>
</div>
css
.bootcn-separator {
  --bootcn-separator-spacing: 1rem;
  --bootcn-separator-color: var(--bootcn-border-color);

  flex-shrink: 0;
  margin: var(--bootcn-separator-spacing) 0;
  border: 0;
  border-top: var(--bootcn-border-width) solid var(--bootcn-separator-color);
  opacity: 1;
}

.bootcn-separator--vertical {
  align-self: stretch;
  width: 0;
  height: auto;
  margin: 0 var(--bootcn-separator-spacing);
  border-top: 0;
  border-left: var(--bootcn-border-width) solid var(--bootcn-separator-color);
}

.bootcn-separator-label {
  --bootcn-separator-spacing: 1rem;
  --bootcn-separator-color: var(--bootcn-border-color);

  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: var(--bootcn-separator-spacing) 0;
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
}

.bootcn-separator-label::before,
.bootcn-separator-label::after {
  content: '';
  flex: 1 1 0;
  border-top: var(--bootcn-border-width) solid var(--bootcn-separator-color);
}

.bootcn-separator-label__text {
  white-space: nowrap;
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.