Last active
October 19, 2022 23:20
-
-
Save MrGrigri/907466afd1a54cfcb5588e2092de9f38 to your computer and use it in GitHub Desktop.
Used to animate the outline offset when an interactive element receives focus only when it's visible.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--outline-color: #346ebd; | |
--outline: 2px solid var(--outline-color); | |
} | |
* { | |
outline-offset: -2px; | |
} | |
*:not(:active):focus-visible { | |
outline: var(--outline); | |
outline-offset: 2px; | |
} | |
.focus-visible:has(:not(:active):focus-visible) { | |
outline: var(--outline); | |
outline-offset: 2px; | |
} | |
.focus-visible:has(:not(:active):focus-visible) :focus-visible { | |
outline: none; | |
} | |
@media (prefers-reduced-motion: no-preference) { | |
* { | |
will-change: outline-offset; | |
transition: outline-offset 75ms ease-out; | |
} | |
*:not(:active):focus-visible, | |
.focus-visible:has(:not(:active):focus-visible) { | |
transition: outline-offset 25ms ease-out; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example Video
Screen.Recording.2022-10-06.at.12.35.12.mov