Skip to content

Commit 8b20bce

Browse files
Add Sass variable for prefers-reduced-motion, add callout to affected components (#27581)
* Tweak the accessibility/reduced motion text include mention of carousel slides, remove the (now inaccurate, as Firefox 63 includes it too) mention that support is limited to Safari/macOS xref #27525 * Add new callout for reduced motion * Add variable to control prefers-reduced-motion media query support * Add callout about prefers-reduced-motion to all components currently using animation which are affected
1 parent f7a4b39 commit 8b20bce

File tree

11 files changed

+32
-12
lines changed

11 files changed

+32
-12
lines changed

scss/_variables.scss

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ $yiq-text-light: $white !default;
107107
//
108108
// Quickly modify global styling by enabling or disabling optional features.
109109

110-
$enable-caret: true !default;
111-
$enable-rounded: true !default;
112-
$enable-shadows: false !default;
113-
$enable-gradients: false !default;
114-
$enable-transitions: true !default;
115-
$enable-hover-media-query: false !default; // Deprecated, no longer affects any compiled CSS
116-
$enable-grid-classes: true !default;
117-
$enable-print-styles: true !default;
118-
$enable-validation-icons: true !default;
110+
$enable-caret: true !default;
111+
$enable-rounded: true !default;
112+
$enable-shadows: false !default;
113+
$enable-gradients: false !default;
114+
$enable-transitions: true !default;
115+
$enable-prefers-reduced-motion-media-query: true !default;
116+
$enable-hover-media-query: false !default; // Deprecated, no longer affects any compiled CSS
117+
$enable-grid-classes: true !default;
118+
$enable-print-styles: true !default;
119+
$enable-validation-icons: true !default;
119120

120121

121122
// Spacing

scss/mixins/_transition.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
}
99
}
1010

11-
@media screen and (prefers-reduced-motion: reduce) {
12-
transition: none;
11+
@if $enable-prefers-reduced-motion-media-query {
12+
@media screen and (prefers-reduced-motion: reduce) {
13+
transition: none;
14+
}
1315
}
1416
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% capture callout %}
2+
The animation effect of this component is dependent on the `prefers-reduced-motion` media query. See the [reduced motion section of our accessibility documentation]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/accessibility/#reduced-motion).
3+
{% endcapture %}
4+
{% include callout.html content=callout type="info" %}

site/docs/4.1/components/carousel.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The carousel is a slideshow for cycling through a series of content, built with
1212

1313
In browsers where the [Page Visibility API](https://www.w3.org/TR/page-visibility/) is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).
1414

15+
{% include callout-info-prefersreducedmotion.md %}
16+
1517
Please be aware that nested carousels are not supported, and carousels are generally not compliant with accessibility standards.
1618

1719
Lastly, if you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).

site/docs/4.1/components/collapse.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ toc: true
1010

1111
The collapse JavaScript plugin is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the `height` from its current value to `0`. Given how CSS handles animations, you cannot use `padding` on a `.collapse` element. Instead, use the class as an independent wrapping element.
1212

13+
{% include callout-info-prefersreducedmotion.md %}
14+
1315
## Example
1416

1517
Click the buttons below to show and hide another element via class changes:

site/docs/4.1/components/modal.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ $('#myModal').on('shown.bs.modal', function () {
2323
})
2424
{% endhighlight %}
2525

26+
{% include callout-info-prefersreducedmotion.md %}
27+
2628
Keep reading for demos and usage guidelines.
2729

2830
## Examples

site/docs/4.1/components/navbar.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Here's what you need to know before getting started with the navbar:
1717
- Navbars are hidden by default when printing. Force them to be printed by adding `.d-print` to the `.navbar`. See the [display]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/display/) utility class.
1818
- Ensure accessibility by using a `<nav>` element or, if using a more generic element such as a `<div>`, add a `role="navigation"` to every navbar to explicitly identify it as a landmark region for users of assistive technologies.
1919

20+
{% include callout-info-prefersreducedmotion.md %}
21+
2022
Read on for an example and list of supported sub-components.
2123

2224
## Supported content

site/docs/4.1/components/popovers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Things to know when using the popover plugin:
2121
- When triggered from anchors that wrap across multiple lines, popovers will be centered between the anchors' overall width. Use `.text-nowrap` on your `<a>`s to avoid this behavior.
2222
- Popovers must be hidden before their corresponding elements have been removed from the DOM.
2323

24+
{% include callout-info-prefersreducedmotion.md %}
25+
2426
Keep reading to see how popovers work with some examples.
2527

2628
## Example: Enable popovers everywhere

site/docs/4.1/components/tooltips.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Things to know when using the tooltip plugin:
2020
- When triggered from hyperlinks that span multiple lines, tooltips will be centered. Use `white-space: nowrap;` on your `<a>`s to avoid this behavior.
2121
- Tooltips must be hidden before their corresponding elements have been removed from the DOM.
2222

23+
{% include callout-info-prefersreducedmotion.md %}
24+
2325
Got all that? Great, let's see how they work with some examples.
2426

2527
## Example: Enable tooltips everywhere

site/docs/4.1/getting-started/accessibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For visually hidden interactive controls, such as traditional "skip" links, `.sr
4545

4646
### Reduced motion
4747

48-
Bootstrap includes support for the [`prefers-reduced-motion` media feature](https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion). In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Bootstrap (for instance, when a modal dialog is opened or closed) will be disabled. Currently, support is limited to Safari on macOS and iOS.
48+
Bootstrap includes support for the [`prefers-reduced-motion` media feature](https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion). In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Bootstrap (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled.
4949

5050
## Additional resources
5151

site/docs/4.1/getting-started/theming.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ You can find and customize these variables for key global options in Bootstrap's
237237
| `$enable-shadows` | `true` or `false` (default) | Enables predefined `box-shadow` styles on various components. |
238238
| `$enable-gradients` | `true` or `false` (default) | Enables predefined gradients via `background-image` styles on various components. |
239239
| `$enable-transitions` | `true` (default) or `false` | Enables predefined `transition`s on various components. |
240+
| `$enable-prefers-reduced-motion-media-query` | `true` (default) or `false` | Enables the [`prefers-reduced-motion` media query]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/accessibility/#reduced-motion), which suppresses certain animations/transitions based on the users' browser/operating system preferences. |
240241
| `$enable-hover-media-query` | `true` or `false` (default) | **Deprecated** |
241242
| `$enable-grid-classes` | `true` (default) or `false` | Enables the generation of CSS classes for the grid system (e.g., `.container`, `.row`, `.col-md-1`, etc.). |
242243
| `$enable-caret` | `true` (default) or `false` | Enables pseudo element caret on `.dropdown-toggle`. |

0 commit comments

Comments
 (0)