-
-
Notifications
You must be signed in to change notification settings - Fork 79k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new link utilities, icon link helper, and update colored link hel…
…pers (#37762) * Add new link utilities, update colored link helpers * Remove commented out code * Fixes * Remove examples changes * Fixes and copy * Fix icon-link instances on homepage * Bump bundlewatch * Fix node-sass issue for rgba() function bug * More bundlewatch * One more time after merge * Add callout for a11y * Hover and focus-visible * Add a11y callouts * Remove duplicate for now * More code review feedback
Showing
21 changed files
with
305 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.icon-link { | ||
display: inline-flex; | ||
gap: .375rem; | ||
align-items: center; | ||
text-decoration-color: rgba(var(--#{$prefix}link-color-rgb), var(--#{$prefix}link-opacity, .5)); | ||
text-underline-offset: .5rem; | ||
backface-visibility: hidden; | ||
|
||
> .bi { | ||
flex-shrink: 0; | ||
width: 1em; | ||
height: 1em; | ||
@include transition(.2s ease-in-out transform); | ||
} | ||
} | ||
|
||
.icon-link-hover { | ||
&:hover, | ||
&:focus-visible { | ||
> .bi { | ||
transform: var(--#{$prefix}icon-link-transform, translate3d(.25em, 0, 0)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
layout: docs | ||
title: Icon link | ||
description: Quickly create stylized hyperlinks with Bootstrap Icons or other icons. | ||
group: helpers | ||
aliases: "/docs/5.3/icon-link/" | ||
toc: true | ||
added: 5.3 | ||
--- | ||
|
||
The icon link helper component modifies our default link styles to enhance their appearance and quickly align any pairing of icon and text. Alignment is set via inline flexbox styling and a default `gap` value. We stylize the underline with a custom offset and color. Icons are automatically sized to `1em` to best match their associated text's `font-size`. | ||
|
||
Icon links assume [Bootstrap Icons](https://icons.getbootstrap.com) are being used, but you can use any icon or image you like. | ||
|
||
{{< callout >}} | ||
Icons used here are likely to be purely decorative, which means they should be hidden from assistive technologies using `aria-hidden="true"`, as we've done in our examples. For icons that are more than decorative, provide an appropriate text alternative via `alt` for `<img>` elements `role="img"` and `aria-label` for SVGs. | ||
{{< /callout >}} | ||
|
||
## Example | ||
|
||
Take a regular `<a>` element, add `.icon-link`, and insert an icon on either the left or right of your link text. The icon is automatically sized, placed, and colored. | ||
|
||
{{< example >}} | ||
<a class="icon-link" href="#"> | ||
<svg class="bi" aria-hidden="true"><use xlink:href="#box-seam"></use></svg> | ||
Icon link | ||
</a> | ||
{{< /example >}} | ||
|
||
{{< example >}} | ||
<a class="icon-link" href="#"> | ||
Icon link | ||
<svg class="bi" aria-hidden="true"><use xlink:href="#arrow-right"></use></svg> | ||
</a> | ||
{{< /example >}} | ||
|
||
## Style on hover | ||
|
||
Add `.icon-link-hover` to move the icon to the right on hover. | ||
|
||
{{< example >}} | ||
<a class="icon-link icon-link-hover" href="#"> | ||
Icon link | ||
<svg class="bi" aria-hidden="true"><use xlink:href="#arrow-right"></use></svg> | ||
</a> | ||
{{< /example >}} | ||
|
||
Customize the hover `transform` by overriding the `--bs-icon-link-transform` CSS variable: | ||
|
||
{{< example >}} | ||
<a class="icon-link icon-link-hover" style="--bs-icon-link-transform: translate3d(0, -.125rem, 0);" href="#"> | ||
<svg class="bi" aria-hidden="true"><use xlink:href="#clipboard"></use></svg> | ||
Icon link | ||
</a> | ||
{{< /example >}} | ||
|
||
## Pairs with link utilities | ||
|
||
Modify icon links with any of [our link utilities]({{< docsref "/utilities/link/" >}}) for modifying underline color and offset. | ||
|
||
{{< example >}} | ||
<a class="icon-link icon-link-hover link-success link-underline-success link-underline-opacity-25" href="#"> | ||
Icon link | ||
<svg class="bi" aria-hidden="true"><use xlink:href="#arrow-right"></use></svg> | ||
</a> | ||
{{< /example >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
layout: docs | ||
title: Link | ||
description: Link utilities are used to stylize your anchors to adjust their color, opacity, underline offset, underline color, and more. | ||
group: utilities | ||
toc: true | ||
added: 5.3 | ||
--- | ||
|
||
## Link opacity | ||
|
||
Change the alpha opacity of the link `rgba()` color value with utilities. Please be aware that changes to a color's opacity can lead to links with [*insufficient* contrast]({{< docsref "getting-started/accessibility#color-contrast" >}}). | ||
|
||
{{< example >}} | ||
<p><a class="link-opacity-10" href="#">Link opacity 10</a></p> | ||
<p><a class="link-opacity-25" href="#">Link opacity 25</a></p> | ||
<p><a class="link-opacity-50" href="#">Link opacity 50</a></p> | ||
<p><a class="link-opacity-75" href="#">Link opacity 75</a></p> | ||
<p><a class="link-opacity-100" href="#">Link opacity 100</a></p> | ||
{{< /example >}} | ||
|
||
You can even change the opacity level on hover. | ||
|
||
{{< example >}} | ||
<p><a class="link-opacity-10-hover" href="#">Link hover opacity 10</a></p> | ||
<p><a class="link-opacity-25-hover" href="#">Link hover opacity 25</a></p> | ||
<p><a class="link-opacity-50-hover" href="#">Link hover opacity 50</a></p> | ||
<p><a class="link-opacity-75-hover" href="#">Link hover opacity 75</a></p> | ||
<p><a class="link-opacity-100-hover" href="#">Link hover opacity 100</a></p> | ||
{{< /example >}} | ||
|
||
## Link underlines | ||
|
||
### Underline color | ||
|
||
Change the underline's color independent of the link text color. | ||
|
||
{{< example >}} | ||
{{< link-underline-colors.inline >}} | ||
{{- range (index $.Site.Data "theme-colors") }} | ||
<p><a href="#" class="link-underline-{{ .name }}">{{ .name | title }} underline</a></p> | ||
{{- end -}} | ||
{{< /link-underline-colors.inline >}} | ||
{{< /example >}} | ||
|
||
### Underline offset | ||
|
||
Change the underline's distance from your text. Offset is set in `em` units to automatically scale with the element's current `font-size`. | ||
|
||
{{< example >}} | ||
<p><a href="#">Default link</a></p> | ||
<p><a class="link-offset-1" href="#">Offset 1 link</a></p> | ||
<p><a class="link-offset-2" href="#">Offset 2 link</a></p> | ||
<p><a class="link-offset-3" href="#">Offset 3 link</a></p> | ||
{{< /example >}} | ||
|
||
### Underline opacity | ||
|
||
Change the underline's opacity. Requires adding `.link-underline` to first set an `rgba()` color we use to then modify the alpha opacity. | ||
|
||
{{< example >}} | ||
<p><a class="link-offset-2 link-underline link-underline-opacity-10" href="#">Underline opacity 10</a></p> | ||
<p><a class="link-offset-2 link-underline link-underline-opacity-25" href="#">Underline opacity 25</a></p> | ||
<p><a class="link-offset-2 link-underline link-underline-opacity-50" href="#">Underline opacity 50</a></p> | ||
<p><a class="link-offset-2 link-underline link-underline-opacity-75" href="#">Underline opacity 75</a></p> | ||
<p><a class="link-offset-2 link-underline link-underline-opacity-100" href="#">Underline opacity 100</a></p> | ||
{{< /example >}} | ||
|
||
### Hover variants | ||
|
||
Just like the `.link-opacity-*-hover` utilities, `.link-offset` and `.link-underline-opacity` utilities include `:hover` variants by default. Mix and match to create unique link styles. | ||
|
||
{{< example >}} | ||
<a class="link-offset-2 link-offset-3-hover link-underline link-underline-opacity-25 link-underline-opacity-75-hover" href="#"> | ||
Underline opacity 10 | ||
</a> | ||
{{< /example >}} | ||
|
||
## Colored links | ||
|
||
[Colored link helpers]({{< docsref "/helpers/colored-links/" >}}) have been updated to pair with our link utilities. Use the new utilities to modify the link opacity, underline opacity, and underline offset. | ||
|
||
{{< example >}} | ||
{{< colored-links.inline >}} | ||
{{- range (index $.Site.Data "theme-colors") }} | ||
<p><a href="#" class="link-{{ .name }} link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover">{{ .name | title }} link</a></p> | ||
{{- end -}} | ||
{{< /colored-links.inline >}} | ||
{{< /example >}} | ||
|
||
{{< callout info >}} | ||
{{< partial "callouts/warning-color-assistive-technologies.md" >}} | ||
{{< /callout >}} | ||
|
||
## Sass | ||
|
||
In addition to the following Sass functionality, consider reading about our included [CSS custom properties]({{< docsref "/customize/css-variables" >}}) (aka CSS variables) for colors and more. | ||
|
||
### Utilities API | ||
|
||
Link utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}}) | ||
|
||
{{< scss-docs name="utils-links" file="scss/_utilities.scss" >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters