Skip to main content

Helpers

Vertical rule

A one-pixel vertical divider that stretches to the height of its flex row.

How it works

.vr is the vertical cousin of <hr>. It is an inline-block, --bs-border-width (1px) wide, painted in currentcolor at 25 % opacity, with min-height: 1em. Inside a flex container it uses align-self: stretch to fill the row.

HTML
<div class="vr"></div>

Give it an explicit height when it is not in a flex row.

HTML
<div class="vr" style="height: 100px"></div>

With stacks

The natural home for .vr is an .hstack, where it becomes a full-height divider.

First item
Second item
Third item
HTML
<div class="hstack gap-3">
  <div class="p-2 bg-body-secondary border rounded-1">First item</div>
  <div class="p-2 ms-auto bg-body-secondary border rounded-1">Second item</div>
  <div class="vr"></div>
  <div class="p-2 bg-body-secondary border rounded-1">Third item</div>
</div>

A "tale of the tape" strip: stats separated by rules, in the theme's mono .stat treatment.

Height6'4"
Weight275 lb
FromParts Unknown
Record31–4
HTML
<div class="hstack gap-4 text-bg-navy p-3 rounded-1 stat">
  <div><small class="d-block opacity-75">Height</small>6'4"</div>
  <div class="vr"></div>
  <div><small class="d-block opacity-75">Weight</small>275 lb</div>
  <div class="vr"></div>
  <div><small class="d-block opacity-75">From</small>Parts Unknown</div>
  <div class="vr"></div>
  <div><small class="d-block opacity-75">Record</small>31–4</div>
</div>

Color and opacity

Because the rule is currentcolor, a text colour utility recolours it; use .opacity-* to override the default 25 %.

HTML
<div class="hstack gap-3" style="height: 3rem">
  <div class="vr"></div>
  <div class="vr text-primary opacity-100"></div>
  <div class="vr text-danger opacity-75"></div>
  <div class="vr text-navy opacity-50"></div>
  <div class="vr" style="width: 3px"></div>
</div>

CSS

.vr {
  display: inline-block;
  align-self: stretch;
  width: var(--bs-border-width);
  min-height: 1em;
  background-color: currentcolor;
  opacity: 0.25;
}

$hr-opacity: .25 and $border-width: 1px are the two Sass variables involved. The theme keeps both at Bootstrap's defaults.