From: Mark Otto Date: Wed, 22 Apr 2026 02:21:15 +0000 (-0700) Subject: Revamp focus ring helper and docs (#42350) X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=00a77a195ca601b86e6c0f295eb19f548c0ea9fd;p=thirdparty%2Fbootstrap.git Revamp focus ring helper and docs (#42350) * Revamp focus ring helper and docs * remove util --- diff --git a/scss/_utilities.scss b/scss/_utilities.scss index f42f7fc123..2779b25daf 100644 --- a/scss/_utilities.scss +++ b/scss/_utilities.scss @@ -114,14 +114,6 @@ $utilities: map.merge( ) ), // scss-docs-end utils-shadow - // scss-docs-start utils-focus-ring - "focus-ring": ( - // css-var: true, - property: --focus-ring-color, - class: focus-ring, - values: theme-color-values("focus-ring"), - ), - // scss-docs-end utils-focus-ring // scss-docs-start utils-position "position": ( property: position, diff --git a/scss/helpers/_focus-ring.scss b/scss/helpers/_focus-ring.scss index 9497156893..c210d8d385 100644 --- a/scss/helpers/_focus-ring.scss +++ b/scss/helpers/_focus-ring.scss @@ -1,5 +1,6 @@ @layer helpers { .focus-ring:focus-visible { - outline: var(--focus-ring); + // outline: var(--focus-ring); + outline: var(--focus-ring-width) solid var(--theme-focus-ring, var(--focus-ring-color)); } } diff --git a/site/src/content/docs/helpers/focus-ring.mdx b/site/src/content/docs/helpers/focus-ring.mdx index 8e0575d991..30b73182f8 100644 --- a/site/src/content/docs/helpers/focus-ring.mdx +++ b/site/src/content/docs/helpers/focus-ring.mdx @@ -6,50 +6,26 @@ toc: true import { getData } from '@libs/data' -The `.focus-ring` helper modifies the default `outline` for focus states with one that can be more easily customized. The new focus ring is made up of a series of CSS variables, inherited from the `:root` level, that can be modified for any element or component. +The `.focus-ring` helper modifies the default `outline` for focus states with one that can be more easily customized. Focus ring 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 directly on the link below to see the focus ring in action, or into the example below and then press Tab. +Tab into the example below to see the focus ring in action, or into the example below and then press Tab. Custom focus ring `} /> -## Customize +## Variants -Modify the styling of a focus ring with our CSS variables, Sass variables, utilities, or custom styles. +Change the color of the focus ring with the [theme color]([[docsref:/customize/theme#theme-colors]]) utility classes. The helper class pulls in the `--bs-theme-focus-ring` CSS variable for the given theme color. -### CSS variables + `${themeColor.title} focus`)} /> -Modify the `--bs-focus-ring-*` CSS variables as needed to change the default appearance. +## Custom colors - - Green focus ring - `} /> - -`.focus-ring` sets styles via global CSS variables that can be overridden on any parent element, as shown above. These variables are generated from their Sass variable counterparts. - - +Modify the `--bs-focus-ring-color` CSS variable as needed to change the default appearance. Use existing theme variables or your own colors. When using your own colors, we recommend using `light-dark()` for color mode support and `color-mix()` to ensure colors deviate slightly for more contrast on different backgrounds. -By default, there is no `--bs-focus-ring-x`, `--bs-focus-ring-y`, or `--bs-focus-ring-blur`, but we provide CSS variables with fallbacks to initial `0` values. Modify them to change the default appearance. - - - Blurry offset focus ring + + Green focus ring `} /> - -### Sass variables - -Customize the focus ring Sass variables to modify all usage of the focus ring styles across your Bootstrap-powered project. - -{/* */} - -### Sass utilities API - -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]([[docsref:/customize/color#theme-colors]]). Note that the light and dark variants may not be visible on all background colors given current color mode support. - - `

${themeColor.title} focus

`)} /> - -Focus ring utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]([[docsref:/utilities/api#using-the-api]]) - -