Skip to content

Remove Outline for Mouse Interactions #781

@michaelmang

Description

@michaelmang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions