Skip to content
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

Remove Outline for Mouse Interactions #781

Open
michaelmang opened this issue Oct 26, 2020 · 1 comment
Open

Remove Outline for Mouse Interactions #781

michaelmang opened this issue Oct 26, 2020 · 1 comment

Comments

@michaelmang
Copy link

michaelmang commented Oct 26, 2020

The :focus-visible trick
“What if we could apply focus styles only when the keyboard is used to focus something, not the mouse?” asks Chris in this blog post all about that and the :focus-visible trick. Chris points to Lea Verou’s suggestion several years ago now to remove the outline from all elements that are focused with a mouse:

:focus:not(:focus-visible) { outline: none }
I like this suggestion a lot and I think I’m going to add it to my newly refactored base.less file; that’s where we keep all global styles like h1, p, etc. Back to the refactoring!

Screen Shot 2020-10-26 at 12 46 53 PM

Summary

Make the suggested CSS change so that outlines are only shown on keyboard interactions, not mouse interactions. Example: Click on the accordion.

Screen Shot 2020-10-27 at 9 37 23 AM

Using the trick shown in the tweet, it will only apply to browsers that support the :focus-visible selector.

@100stacks
Copy link
Member

@michaelmang, have you see this article:

https://blog.chromium.org/2020/03/updates-to-form-controls-and-focus.html

It explains why the focus ring is more pronounced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants