Focus ring via :focus-visible
See original GitHub issueDescription
It may be desirable to remove the default focus ring which appears on mouse click. For <model-viewer>
to be accessible and compliant there must be a focus ring visible when keyboard users interact with the model. This is a requirement from WCAG 2.4.7 Focus Visible.
A possible work-around would be to implement the :focus-visible
polyfill which, I assume, would be encapsulated within <model-viewer>
. With this in place, we’d be free to remove the outline for mouse/touch, and display the outline for keyboard only.
/*
Provide basic, default focus styles.
*/
canvas:focus {
…
}
/*
Remove default focus styles for mouse users ONLY if
:focus-visible is supported on this platform.
*/
canvas:focus:not(:focus-visible) {
…
}
/*
Optionally: If :focus-visible is supported on this
platform, provide enhanced focus styles for keyboard
focus.
*/
canvas:focus-visible {
…
}
Live Demo
Browser Affected
- Chrome
- Edge
- Firefox
- Helios
- IE
- Safari
OS
- Android
- iOS
- Linux
- MacOS
- Windows
Versions
- model-viewer: v0.1.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
focus-visible - CSS: Cascading Style Sheets - MDN Web Docs
The :focus-visible pseudo-class applies while an element matches the :focus pseudo-class and the UA (User Agent) determines via heuristics ...
Read more >:focus-visible CSS pseudo-class | Can I use... Support ...
The :focus-visible pseudo-class applies while an element matches the :focus ... should be specially indicated on the element (typically via a “focus ring”)....
Read more >:focus-visible in WebKit - May 2021 - Rego's Everyday Life
These elements have always matched (and still match) :focus by default, and have usually showed a focus ring when focused via mouse click....
Read more >The :focus-visible Trick | CSS-Tricks
This prevents the focus ring from appearing on mousedown on desktop or touch on mobile… If you want a custom style when the...
Read more >Focus Visible - Understanding Success Criterion 2.4.7
2.4.7 Focus Visible: Any keyboard operable user interface has a mode of operation where the keyboard focus indicator is visible. (Level AA) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/WICG/focus-visible/pull/196 as been approved, so we should be able to move forward with a aspirational integration.
I have opened https://github.com/WICG/focus-visible/pull/196 to add Shadow DOM support.