Accessibility
A brief overview of Boosted’s features and limitations for the creation of accessible content.
Boosted provides an easy-to-use framework of ready-made styles, layout tools, and interactive components, allowing developers to create websites and applications that are visually appealing, functionally rich, and accessible out of the box.
Overview and limitations
The overall accessibility of any project built with Boosted depends in large part on the author’s markup, additional styling, and scripting they’ve included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Boosted that fulfill WCAG 2.1 (A/AA/AAA), Section 508, and similar accessibility standards and requirements.
Structural markup
Boosted’s styling and layout can be applied to a wide range of markup structures. This documentation aims to provide developers with best practice examples to demonstrate the use of Boosted itself and illustrate appropriate semantic markup, including ways in which potential accessibility concerns can be addressed.
Interactive components
Boosted’s interactive components—such as modal dialogs, dropdown menus, and custom tooltips—are designed to work for touch, mouse, and keyboard users. Through the use of relevant WAI-ARIA roles and attributes, these components should also be understandable and operable using assistive technologies (such as screen readers).
Because Boosted’s components are purposely designed to be fairly generic, authors may need to include further ARIA roles and attributes, as well as JavaScript behavior, to more accurately convey the precise nature and functionality of their component. This is usually noted in the documentation.
Color contrast
Some combinations of colors that currently make up Boosted’s default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—may lead to insufficient color contrast (below the recommended WCAG 2.1 text color contrast ratio of 4.5:1 and the WCAG 2.1 non-text color contrast ratio of 3:1), particularly when used against a light background.
Unlike Bootstrap, in Boosted contrasts are locked to ensure they meet WCAG 2.1 accessibility standards for color contrast when using .text-*
and .bg-*
utilities, by defining color
and background-color
altogether. Please refer to our theme colors to have a full preview of Boosted color palette’s reached WCAG level.
Visually hidden content
Content which should be visually hidden, but remain accessible to assistive technologies such as screen readers, can be styled using the .visually-hidden
class. This can be useful in situations where additional visual information or cues (such as meaning denoted through the use of color) need to also be conveyed to non-visual users.
<p class="text-danger">
<span class="visually-hidden">Danger: </span>
This action is not reversible
</p>
For visually hidden interactive controls, such as traditional “skip” links, use the .visually-hidden-focusable
class. This will ensure that the control becomes visible once focused (for sighted keyboard users). Watch out, since Boosted 5 .visually-hidden-focusable
is a standalone class, and must not be used in combination with the .visually-hidden
class.
<a class="visually-hidden-focusable" href="#content">Skip to main content</a>
Reduced motion
Boosted includes support for the prefers-reduced-motion
media feature. In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Boosted (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled, and meaningful animations (such as spinners) will be slowed down.
On browsers that support prefers-reduced-motion
, and where the user has not explicitly signaled that they’d prefer reduced motion (i.e. where prefers-reduced-motion: no-preference
), Boosted enables smooth scrolling using the scroll-behavior
property.
Focus visibility
Boosted includes WICG’s :focus-visible
polyfill to ensure an enhanced focus visibility for keyboard users while shutting down focus styles on active state.
:focus {
@include focus-visible(); // 1
}
.js-focus-visible :focus:not([data-focus-visible-added]):not(.focus-ring):not(.form-select:invalid):not(.form-control[type="file"]:invalid),
.js-focus-visible .focus:not([data-focus-visible-added]):not(.focus-ring):not(.form-select:invalid):not(.form-control[type="file"]:invalid) { // 2
outline: 0 !important;
box-shadow: none;
}
:focus:not(:focus-visible):not(.focus-ring):not(.form-select:invalid):not(.form-control[type="file"]:invalid) { // 3
outline: 0 !important;
box-shadow: none;
}
Added in v5.2.3
Boosted provides focus-visible()
mixin to ensure a proper visible focus state:
@mixin focus-visible($zindex: $focus-visible-zindex, $color: var(--#{$prefix}focus-visible-outer-color), $width: $focus-visible-outer-width, $offset: $focus-visible-outer-offset, $box-width: $focus-visible-inner-width, $box-color: var(--#{$prefix}focus-visible-inner-color)) {
z-index: $zindex;
isolation: isolate;
outline: $width solid $color;
outline-offset: $offset;
box-shadow: 0 0 0 $box-width $box-color;
@include transition($transition-focus);
}
This visible focus state is defined by an outer outline and an inner box shadow. Colors are switched in a dark context. Here are the basic variables that define this visible focus:
$focus-visible-zindex: 5; // Boosted mod
$focus-visible-inner-width: 2px; // Boosted mod
$focus-visible-inner-color: $white; // Boosted mod
$focus-visible-outer-width: 3px; // Boosted mod
$focus-visible-outer-offset: $focus-visible-inner-width; // Boosted mod
$focus-visible-outer-color: $black; // Boosted mod
Each component then specifies its own visible focus style when needed, for example carousels.
&:focus {
&[data-focus-visible-added] {
> span {
@include focus-visible();
}
}
}
Under a fixed header
When using a fixed (or sticky) header, tabbing backward often hides focused element under the header. Boosted sets scroll-padding-top
property for such case. This feature is configurable in two ways:
$scroll-offset-top
variable defines the offset,- and
$enable-fixed-header
allows to drop this rule if you don’t use a fixed header.
@if $enable-fixed-header {
scroll-padding-top: $scroll-offset-top * .5;
@include media-breakpoint-up(lg) {
scroll-padding-top: $scroll-offset-top;
}
}
Minimum target size
Boosted provides target-size()
mixin to ensure a minimum target size, adding a centered pseudo-element with a minimum size —defaulting to 44px
to pass WCAG 2.1 “Target Size” Success Criterion (2.5.5)— alongside a few arguments to fit specific needs (e.g. different width and height, using ::after
instead of ::before
, etc.).
@mixin target-size($size: $target-size, $pseudo-element: before, $position: relative, $width: $size, $height: $size) {
position: $position;
&::#{$pseudo-element} {
position: absolute;
top: 50%;
left: 50%;
width: $width;
min-width: 100%;
height: $height;
min-height: 100%;
content: "";
transform: translate3d(-50%, -50%, 0);
}
}
Maximum line length
When writing a paragraph, it is commonly admitted that a line should have 80 characters as a maximum. This phenomenon is carefully explained in the C20 technique: Using relative measurements to set column widths.
For more information, please read text utilities.
Additional resources
- Web Content Accessibility Guidelines (WCAG) 2.1
- The A11Y Project
- MDN accessibility documentation
- Tenon.io Accessibility Checker
- Color Contrast Analyser (CCA)
- “HTML Codesniffer” bookmarklet for identifying accessibility issues
- Microsoft Accessibility Insights
- Deque Axe testing tools
- Orange accessibility guidelines
- Introduction to Web Accessibility
:focus-visible
on MDN