Skip to content

Updated navbar focus styles are an accessibility regression #41395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
nwalters512 opened this issue Apr 21, 2025 · 3 comments
Open
3 tasks done

Updated navbar focus styles are an accessibility regression #41395

nwalters512 opened this issue Apr 21, 2025 · 3 comments

Comments

@nwalters512
Copy link
Contributor

Prerequisites

Describe the issue

The updated navbar focus styles introduced in #33125 provide insufficient contrast with the background.

Here's what the focus indicators looked like prior to that change when using the browser's default focus styles:

Image

The focus indicator may not be pretty, but it's very very visible!

Reduced test cases

It's reproducible in the "Color schemes" section of the Navbar documentation: https://getbootstrap.com/docs/5.3/components/navbar/#color-schemes. In the following screenshot, I've forced the <a> elements for "Home" to display as :focus-visible:

Image

In the first and third ones, the contrast is insufficient (1.29:1 and 1.37:1, respectively), and in the second, the focus indicator is completely invisible.

What operating system(s) are you seeing the problem on?

macOS

What browser(s) are you seeing the problem on?

Chrome, Safari, Firefox

What version of Bootstrap are you using?

v5.3.5

@DhawalChaturvedi

This comment has been minimized.

@julien-deramond
Copy link
Member

I'm mentioning this here as it could offer a more global solution: in Boosted at Orange (fork of Bootstrap), we implemented a double outline for visible focus states, ensuring there's always a fallback "security" outline. Since the Orange brand colors are mostly black/white or white/black, usually only one outline color is visible — but on colored backgrounds, both outlines show up, improving accessibility.

You can see the relevant implementation here:

https://github.com/Orange-OpenSource/Orange-Boosted-Bootstrap/blob/c06298eb9b4e6d026aef26fa49ead2c96ec29a44/scss/_variables.scss#L653-L662

I haven't tested it yet, but we could potentially set the outer border color to primary and the inner one to "bg body", which should cover most use cases. Something along those lines could work for a generic approach, but still customizable by users.

If we want to be more confident in the results, considering that most of Bootstrap's users don't use Sass to customize the rendering, defaulting to white and black — regardless of the brand — is probably the safest approach, as it tends probably to be more visible in any case.

@nwalters512
Copy link
Contributor Author

A double black/white outline is pretty close to what the auto style does, at least in Chrome + Firefox (Safari uses a single blue color by default, which isn't super accessible). I think this is a very good option.

If it's possible, it'd be nice for the colors involved to be CSS variables that we could override, either globally or in a particular context based on our knowledge of what would be accessible, look visually appealing, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

4 participants