Skip to content

Commit ebfef18

Browse files
authored
Merge pull request bchiang7#165 from gupta-ji6/css/focus-visible-polyfill
add :focus-visible global styles with polyfill
2 parents 9bd5fd3 + cc18294 commit ebfef18

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/styles/GlobalStyle.js

+20
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,31 @@ const GlobalStyle = createGlobalStyle`
2525
color: var(--lightest-slate);
2626
}
2727
28+
/* Provide basic, default focus styles.*/
2829
:focus {
2930
outline: 2px dashed var(--green);
3031
outline-offset: 3px;
3132
}
3233
34+
/*
35+
Remove default focus styles for mouse users ONLY if
36+
:focus-visible is supported on this platform.
37+
*/
38+
:focus:not(:focus-visible) {
39+
outline: none;
40+
outline-offset: 0px;
41+
}
42+
43+
/*
44+
Optionally: If :focus-visible is supported on this
45+
platform, provide enhanced focus styles for keyboard
46+
focus.
47+
*/
48+
:focus-visible {
49+
outline: 2px dashed var(--green);
50+
outline-offset: 3px;
51+
}
52+
3353
/* Scrollbar Styles */
3454
html {
3555
scrollbar-width: thin;

0 commit comments

Comments
 (0)