bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

feat: improve focus accessibility with high contrast mode support

Open SH20RAJ opened this issue 5 months ago • 1 comments

  • Add outline fallbacks for form controls in high contrast mode
  • Add outline fallbacks for button focus states in high contrast mode
  • Ensure focus indicators remain visible when box-shadow is disabled
  • Include test file demonstrating accessibility improvements

Fixes accessibility issue where focus indicators become invisible in high contrast mode or when users disable box-shadow effects.

Changes:

  • scss/forms/_form-control.scss: Added @media (prefers-contrast: high) with outline fallback
  • scss/_buttons.scss: Added @media (prefers-contrast: high) with outline fallback for focus-visible
  • test-high-contrast-focus.html: Test page demonstrating the improvements

The compiled CSS now includes:

.form-control:focus { /* existing styles */ }
@media (prefers-contrast: high) {
  .form-control:focus { outline: 2px solid; outline-offset: 2px; } }

.btn:focus-visible { /* existing styles */ }
@media (prefers-contrast: high) {
  .btn:focus-visible { outline: 2px solid; outline-offset: 2px; } }

Description

Motivation & Context

Type of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Refactoring (non-breaking change)
  • [ ] Breaking change (fix or feature that would change existing functionality)

Checklist

  • [x] I have read the contributing guidelines
  • [x] My code follows the code style of the project (using npm run lint)
  • [x] My change introduces changes to the documentation
  • [x] I have updated the documentation accordingly
  • [x] I have added tests to cover my changes
  • [x] All new and existing tests passed

Live previews

Related issues

SH20RAJ avatar Aug 30 '25 03:08 SH20RAJ

Thanks for the PR! Please do not commit dist files, please. Also your test page would better be a CodePen or something, not commited to Bootstrap's repo neither.

ffoodd avatar Oct 14 '25 14:10 ffoodd