-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
86 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// stylelint-disable indentation, function-disallowed-list, declaration-colon-newline-after, value-list-comma-newline-after, value-list-comma-space-after | ||
|
||
.focus-ring:focus { | ||
outline: 0; | ||
// By default, there is no `--bs-focus-ring-x` or `--bs-focus-ring-y`, but we provide CSS variables with fallbacks to initial `0` values | ||
box-shadow: 0 0 0 var(--#{$prefix}focus-ring-offset-width) var(--#{$prefix}focus-ring-offset-color, var(--#{$prefix}body-bg)), | ||
var(--#{$prefix}focus-ring-x, 0) | ||
var(--#{$prefix}focus-ring-y, 0) | ||
var(--#{$prefix}focus-ring-blur) | ||
calc(var(--#{$prefix}focus-ring-width) + var(--#{$prefix}focus-ring-offset-width)) | ||
var(--#{$prefix}focus-ring-color); | ||
} | ||
|
||
@each $state, $value in $theme-colors { | ||
.focus-ring-#{$state}:focus { --#{$prefix}focus-ring-color: rgba(#{to-rgb($value)}, var(--bs-focus-ring-opacity)); } | ||
} |
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,49 @@ | ||
--- | ||
layout: docs | ||
title: Focus ring | ||
description: Utility classes that allows you to add and modify custom focus ring styles to elements and components. | ||
group: helpers | ||
toc: true | ||
--- | ||
|
||
The `.focus-ring` helper removes the default `outline` on `:focus`, replacing it with a `box-shadow` that can be more broadly customized. The new shadow is made up of a series of CSS variables, inherited from the `:root` level, that can be modified for any element or component. | ||
|
||
## Example | ||
|
||
Click into the example below and press <kbd>Tab</kbd> to see the focus ring in action. | ||
|
||
{{< example >}} | ||
<a href="#" class="d-inline-flex focus-ring py-1 px-2 text-decoration-none border rounded-2"> | ||
Custom focus ring | ||
</a> | ||
{{< /example >}} | ||
|
||
## Customize | ||
|
||
Modify the styling of a focus ring with our CSS variables, Sass variables, utilities, or custom styles. | ||
|
||
### CSS variables | ||
|
||
Modify the `--bs-focus-ring-*` CSS variables as needed to change the default appearance. | ||
|
||
{{< example >}} | ||
<a href="#" class="d-inline-flex focus-ring py-1 px-2 text-decoration-none border rounded-2" style="--bs-focus-ring-color: rgba(var(--bs-success-rgb), .25)"> | ||
Green focus ring | ||
</a> | ||
{{< /example >}} | ||
|
||
### Sass | ||
|
||
Customize the Sass variables to modify all usage of the focus ring styles across your Bootstrap-powered project. | ||
|
||
{{< scss-docs name="focus-ring-variables" file="scss/_variables.scss" >}} | ||
|
||
### Utilities | ||
|
||
In addition to `.focus-ring`, we have several `.focus-ring-*` utilities to modify the helper class defaults. Modify the color with any of our theme colors. | ||
|
||
{{< example >}} | ||
<a href="#" class="d-inline-flex focus-ring focus-ring-danger py-1 px-2 text-decoration-none border rounded-2"> | ||
Danger focus ring | ||
</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