coliff / bootstrap-forced-colors-css
Bootstrap 5 Forced Colors CSS for Windows High Contrast Themes
Fund package maintenance!
Paypal
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 0
Open Issues: 2
Language:HTML
This package is auto-updated.
Last update: 2024-11-01 09:49:19 UTC
README
Bootstrap Forced Colors CSS
Enhances the accessibility of Bootstrap 5 when using with Contrast themes in Windows.
This CSS file fixes many issues and adds enhancements to make Bootstrap 5 more accessible in Firefox, Chrome, Edge on Windows using the forced-colors: active
media query.
Quick start
- Download the latest release
- Clone the repository
git clone https://github.com/coliff/bootstrap-forced-colors-css.git
- Install with npm
npm install bootstrap-forced-colors-css
- Install with Yarn
yarn add bootstrap-forced-colors-css
- Install with Composer
composer require coliff/bootstrap-forced-colors-css
Usage
Add this in the <head>
which will load the CSS using a media query as follow:
<link rel="stylesheet" href="/css/bootstrap-forced-colors.min.css" media="screen and (forced-colors: active)">
The CSS can be loaded via a CDN:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-forced-colors-css@1.0.7/css/bootstrap-forced-colors.min.css" media="screen and (forced-colors: active)">
Or you can import the CSS into your own CSS file:
@import bootstrap-forced-colors.min.css
Note
bootstrap-forced-colors-css improves the accessibility of Bootstrap 5 for Windows users in forced colors mode, but you should still test your site to ensure it meets your accessibility requirements.
FAQS
What does this fix/improve?
- Accordion buttons have improved contrast in dark mode
- Badges within buttons have a 1px border to improve contrast
- Buttons have improved focus state contrast (2px visible outline rather than 1px)
- Disabled buttons display the correct color using the
GrayText
name - Carousel indicators have background-color issue resolved
- Close button has improved contrast by reducing the opacity
- Dropdown toggle arrows appear correctly (as triangles and not rectangles)
- List Group disabled items display the correct color using the
GrayText
name - Modal backdrop opacity changed from 0.5 to 0.8
- Navbar Menu (hamburger) toggle icons display correctly
- Navs Improves active and focus state contrast
- Pagination: Active page link has outline to indicate active page
- Pagination: Disabled page link display the correct color using the
GrayText
name - Placeholder: Fix for invisible placeholder boxes
- Popovers: Fixes invisible arrow issue
- Progress: Is no longer invisible
- Progress: Improved stacked progress bar contrast
- Spinners: Fixes animation
- Tables: Have a 1px outline to improve contrast
- Toasts: Fixes invisible close/dismiss button
- Tooltips: Fix for arrows appearing as rectangles
- Tooltips: Add 1px border to tooltips content
- Vertical Rule: Fixes invisible vertical rule
- Horizontal Rule: Improves contrast by changing opacity from 0.25 to 0.5
Known Issues
- Check the open issues at GitHub.
Demo
See this in action at: https://coliff.github.io/bootstrap-forced-colors-css/tests/
Testing
Currently, only Windows 10 & 11 with Edge, Firefox, and Chrome support forced colors mode. To test, you can enable forced colors mode in:
- Windows 10: Go to
Settings > Ease of Access > High contrast
and select a theme. - Windows 11: Go to
Settings > Accessibility > Contrast themes
and select a theme.
You can also use the Forced Colors Mode Emulation in Edge and Chrome on all platforms.
Note
By default, the Forced Colors Mode emulation is a dark mode theme, but you can switch to a light theme by forcing the prefers-color-scheme
to light in the Dev Tools. Remember that the user can't use Bootstrap's light/dark mode theme toggle. The color scheme is set by the user at the OS level.
Note that CanIUse lists Safari as supporting forced colors mode, however macOS itself doesn't have a Forced Colors / High Contrast mode which means it's not possible to use this with Safari at all.