Skip to content

Use :focus-visible instead of :focus in stylesheets #390

@davwheat

Description

@davwheat

We should use :focus-visible instead of :focus to style the tabs on focus. This pseudoclass is only true when focus is gained via keyboard navigation, not by any other method, and is how focus is handled on native elements, like buttons and links.

This isn't supported in Safari, so we need to perform some acrobatics to keep the old styles working in that browser.

button:focus {
  /* our focus styles */
}

button:focus:not(:focus-visible) {
  /* UNDO our focus styles */
}

Read more:

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