Skip to main content

Helpers

Colored links

Theme-coloured links with hover and focus states, in eleven colours plus body emphasis.

How it works

By default a link in this theme is navy-700 (#122553) and turns gold-700 on hover; in dark mode it is gold-300 and turns gold-500. .link-* swaps that for any theme colour. Hover and focus shift the colour 20 % — darker for light colours, lighter for dark ones — the same way .btn-* does.

Some of these are decorative. Gold-500, gold-300 and cream on the cream page background are well under 4.5:1. Reserve .link-gold, .link-warning, .link-light and .link-cream for dark surfaces such as a .text-bg-navy card, or add .link-underline-opacity-100 so the underline carries the affordance.

Primary link — gold-700, gold-500 in dark mode

Secondary link — navy-300

Success link — green-600

Info link — navy-500

Warning link — gold-300

Danger link — red-600

Light link — cream-50

Dark link — navy-900

Gold link — gold-500

Navy link — navy-700

Cream link — cream-100

Body emphasis link — black, cream-50 in dark mode

HTML
<p><a href="#!" class="link-primary">Primary link</a> — gold-700, gold-500 in dark mode</p>
<p><a href="#!" class="link-secondary">Secondary link</a> — navy-300</p>
<p><a href="#!" class="link-success">Success link</a> — green-600</p>
<p><a href="#!" class="link-info">Info link</a> — navy-500</p>
<p><a href="#!" class="link-warning">Warning link</a> — gold-300</p>
<p><a href="#!" class="link-danger">Danger link</a> — red-600</p>
<p><a href="#!" class="link-light">Light link</a> — cream-50</p>
<p><a href="#!" class="link-dark">Dark link</a> — navy-900</p>
<p><a href="#!" class="link-gold">Gold link</a> — gold-500</p>
<p><a href="#!" class="link-navy">Navy link</a> — navy-700</p>
<p><a href="#!" class="link-cream">Cream link</a> — cream-100</p>
<p class="mb-0"><a href="#!" class="link-body-emphasis">Body emphasis link</a> — black, cream-50 in dark mode</p>

On dark surfaces

The light colours earn their keep on a navy block.

HTML
<div class="text-bg-navy p-3 rounded-1">
  <p>The card is set. Read the <a href="#!" class="link-gold">tale of the tape</a>, check the
  <a href="#!" class="link-cream">venue map</a>, or buy a <a href="#!" class="link-warning">ringside seat</a>.</p>
  <p class="mb-0"><a href="#!" class="link-light link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover">Light link with faded underline that fills on hover</a></p>
</div>

.link-* colours read two variables, --bs-link-opacity and --bs-link-underline-opacity, so the link utilities stack on top without any extra CSS.

HTML
<p><a href="#!" class="link-primary link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover">Primary, underline 25 % until hover</a></p>
<p><a href="#!" class="link-navy link-opacity-50 link-opacity-100-hover">Navy, half-opacity until hover</a></p>
<p><a href="#!" class="link-danger link-underline-gold link-offset-3">Danger text, gold underline, offset 3</a></p>
<p class="mb-0"><a href="#!" class="link-dark link-underline-opacity-0 link-underline-opacity-75-hover">Dark, no underline until hover</a></p>

Every generated class, from dist/rb-bootstrap.css:

  • Colour: .link-{primary|secondary|success|info|warning|danger|light|dark|gold|navy|cream|body-emphasis}
  • Opacity: .link-opacity-{10|25|50|75|100} and -hover variants
  • Underline colour: .link-underline, .link-underline-{primary|…|cream}
  • Underline opacity: .link-underline-opacity-{0|10|25|50|75|100} and -hover variants
  • Underline offset: .link-offset-{1|2|3} and -hover variants

CSS

.link-gold {
  color: RGBA(var(--bs-gold-rgb), var(--bs-link-opacity, 1)) !important;
  text-decoration-color: RGBA(var(--bs-gold-rgb), var(--bs-link-underline-opacity, 1)) !important;
}
.link-gold:hover, .link-gold:focus {
  color: RGBA(221, 191, 95, var(--bs-link-opacity, 1)) !important; /* gold-500 tinted 20% */
  text-decoration-color: RGBA(221, 191, 95, var(--bs-link-underline-opacity, 1)) !important;
}

The hover colour is a fixed hex computed at build time. It does not follow the dark-mode swap of --bs-primary; .link-primary:hover is always #c6a94c.