question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable the accessibility outline for non-keyboard uses

See original GitHub issue

Right now Chakra adds an outline (actually a box-shadow) to elements that receive focus, even when they are focused by clicking the mouse. For example:

image

This is to aid in keyboard accessibility, but it shouldn’t happen when navigating via a mouse—check how popular websites handle this, including GitHub.

It looks like this was somehow integrated in 1.0 but the solution in https://github.com/chakra-ui/chakra-ui/issues/2016#issuecomment-691674038 leads to a broken link.

This behavior has been brought up before (eg. https://github.com/chakra-ui/chakra-ui/issues/2016, https://github.com/chakra-ui/chakra-ui/issues/708, https://github.com/chakra-ui/chakra-ui/issues/574) and the response has been to read this Medium article and implement it. But this is something that 100% of users would need to do to, so it should be fixed in Chakra instead by default.

The current behavior in Chakra is actually encouraging devs to solve it incorrectly, using something like box-shadow: none !important regardless of navigation style (eg. https://github.com/chakra-ui/chakra-ui/issues/708, https://github.com/chakra-ui/chakra-ui/issues/668), and is actually going to result in worse accessibility.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:38
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

26reactions
ianstormtaylorcommented, Feb 25, 2021

@spykr thank you! I was trying to figure out where that was documented.

However I disagree that “100% of users would need to do [this]”, I think it’s purely a personal preference. Hiding focus outlines still makes your site less accessible even if it’s only for non-keyboard users.

I don’t think that’s a good idea for two reasons:

  1. Based on browsing pretty much every popular site, no one does what Chakra does with outlines for non-keyboard navigation. So it’s clearly not a popular choice, and those sites have taken accessibility into account.

  2. Based on the existing issues in this repo, the “fix” people will use for this is to disable the outlines entirely, way worse for accessibility. (You can try to fight this with documentation, but many won’t find it and will just use the nuclear option.)

I really do think that the existing default Chakra has chosen actually hurts accessibility more than helps it.

And it looks like the :focus-visible selector is supported in Chrome, Edge, and Firefox now so this is something that should be baked into Chakra by default, instead of requiring an extra package. (The external package is still a good idea for polyfilling non-supporting browsers like Safari.)

14reactions
ianstormtaylorcommented, Mar 31, 2021

^ I don’t think this bot is configured correctly to make Chakra better.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quick tip: Never remove CSS outlines - The A11Y Project
Removing outlines in CSS creates issues for people navigating the web with a keyboard. Using the CSS rule :focus { outline: none; } ......
Read more >
how to remove CSS outlines in an accessible manner? - TPGi
Apply CSS outline:none rules using JavaScript ONLY IF mouse user depressesing the mouse button is detected. Remove the rules again IF keyboard ...
Read more >
CSS outline property - outline: none and outline: 0
The CSS outline property is an accessibility requirement, yet often abused by many web designers, why do they do it?
Read more >
How to Meet WCAG (Quick Reference) - W3C
A customizable quick reference to Web Content Accessibility Guidelines (WCAG) 2 ... 1.4.1 Use of Color; 1.4.2 Audio Control; 1.4.3 Contrast (Minimum) ...
Read more >
Removing that ugly :focus ring (and keeping it too) - Medium
button:focus { outline: none; }. [brushes hands theatrically]. But hold on a minute, what about those users that don't/can't use a pointing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found