Added in v5.1

Vertical rule

Use the custom vertical rule helper to create vertical dividers like the <hr> element.

How it works

Vertical rules are inspired by the <hr> element, allowing you to create vertical dividers in common layouts. They’re styled just like <hr> elements:

  • They’re 1px wide
  • They have min-height of 1em
  • Their color is set via currentColor and opacity

Customize them with additional styles as needed.

Example

Vertical rule - 图1

html

  1. <div class="vr"></div>

Vertical rules scale their height in flex layouts:

Vertical rule - 图2

html

  1. <div class="d-flex" style="height: 200px;">
  2. <div class="vr"></div>
  3. </div>

With stacks

They can also be used in stacks:

Vertical rule - 图3

html

  1. <div class="hstack gap-3">
  2. <div class="p-2">First item</div>
  3. <div class="p-2 ms-auto">Second item</div>
  4. <div class="vr"></div>
  5. <div class="p-2">Third item</div>
  6. </div>

CSS

Sass variables

Customize the vertical rule Sass variable to change its width.

scss/_variables.scss

  1. $vr-border-width: var(--#{$prefix}border-width);