-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new link utilities, icon link helper, and update colored link helpers #37762
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1afaa89
Add new link utilities, update colored link helpers
mdo d081832
Remove commented out code
mdo 0337202
Fixes
mdo 466921f
Remove examples changes
mdo 0463c58
Fixes and copy
mdo 629e058
Fix icon-link instances on homepage
mdo 4d998ac
Bump bundlewatch
mdo 34e8bef
Fix node-sass issue for rgba() function bug
mdo 49f78ac
More bundlewatch
mdo 930e012
One more time after merge
mdo 3c9c440
Add callout for a11y
mdo 034ff78
Hover and focus-visible
mdo 250b3ef
Add a11y callouts
mdo e15878f
Remove duplicate for now
mdo 97f3d67
More code review feedback
mdo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 >}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why rem over em?