Skip to content

Commit

Permalink
Add link color rgb vars, document usage in Reboot docs
Browse files Browse the repository at this point in the history
Fixes #37081
  • Loading branch information
mdo committed Oct 6, 2022
1 parent 74d10fc commit e867054
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scss/_reboot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ sup { top: -.5em; }
// Links

a {
color: var(--#{$prefix}link-color);
color: rgba(var(--#{$prefix}link-color-rgb), var(--#{$prefix}link-opacity, 1));
text-decoration: $link-decoration;

&:hover {
color: var(--#{$prefix}link-hover-color);
color: rgba(var(--#{$prefix}link-hover-color-rgb), var(--#{$prefix}link-opacity, 1));
text-decoration: $link-hover-decoration;
}
}
Expand Down
2 changes: 2 additions & 0 deletions scss/_root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
--#{$prefix}heading-color: #{$headings-color};
--#{$prefix}link-color: #{$link-color};
--#{$prefix}link-hover-color: #{$link-hover-color};
--#{$prefix}link-color-rgb: #{to-rgb($link-color)};
--#{$prefix}link-hover-color-rgb: #{to-rgb($link-hover-color)};

--#{$prefix}code-color: #{$code-color};
--#{$prefix}highlight-bg: #{$mark-bg};
Expand Down
9 changes: 8 additions & 1 deletion site/content/docs/5.2/content/reboot.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,19 @@ All heading elements—e.g., `<h1>`—and `<p>` are reset to have their `margin-

## Links

Hyperlinks have a default `color` and underline applied. While links change on `:hover`, they don't change based on whether someone `:visited` the link. They also receive no special `:focus` styles.
Links have a default `color` and underline applied. While links change on `:hover`, they don't change based on whether someone `:visited` the link. They also receive no special `:focus` styles.

{{< example >}}
<a href="#">This is an example link</a>
{{< /example >}}

As of v5.3.x, link `color` is set using `rgba()` and new `-rgb` CSS variables, allowing for easy customization of link color opacity. Change the link color opacity with the `--bs-link-opacity` CSS variable:

{{< example >}}
<a href="#" style="--bs-link-opacity: .5">This is an example link</a>
{{< /example >}}


Placeholder links—those without an `href`—are targeted with a more specific selector and have their `color` and `text-decoration` reset to their default values.

{{< example >}}
Expand Down

0 comments on commit e867054

Please sign in to comment.