@@ -4,6 +4,11 @@ $rct-label-hover: rgba($rct-icon-color, .1) !default;
44$rct-label-active : rgba ($rct-icon-color , .15 ) !default ;
55$rct-clickable-hover : rgba ($rct-icon-color , .1 ) !default ;
66$rct-clickable-focus : rgba ($rct-icon-color , .2 ) !default ;
7+ $rct-checkbox-outline-offset : 2px !default ;
8+ $rct-outline-color : rgba ($rct-icon-color , .5 ) !default ;
9+ $rct-outline-radius : 2px ;
10+ $rct-outline-size : 2px !default ;
11+ $rct-outline-offset : -2px !default ;
712
813// Force ASCII output until Sass supports it
914// https://github.com/sass/dart-sass/issues/568
@@ -30,20 +35,38 @@ $rct-clickable-focus: rgba($rct-icon-color, .2) !default;
3035 }
3136 }
3237
38+ button ,
39+ input {
40+ & :focus {
41+ outline : $rct-outline-size solid $rct-outline-color ;
42+ border-radius : $rct-outline-radius ;
43+ }
44+
45+ & :not (:focus-visible ) {
46+ outline : none ;
47+ }
48+ }
49+
3350 button {
3451 line-height : normal ;
3552 color : inherit ;
3653
3754 & :disabled {
3855 cursor : not-allowed ;
3956 }
57+
58+ & :focus {
59+ outline-offset : $rct-outline-offset ;
60+ }
4061 }
4162
4263 .rct-bare-label {
4364 cursor : default ;
4465 }
4566
4667 label {
68+ display : flex ;
69+ align-items : center ;
4770 margin-bottom : 0 ;
4871 cursor : pointer ;
4972
@@ -57,12 +80,32 @@ $rct-clickable-focus: rgba($rct-icon-color, .2) !default;
5780 }
5881 }
5982
60- & :not (.rct-native-display ) input {
61- display : none ;
83+ input {
84+ margin : 0 5px ;
85+ cursor : pointer ;
86+
87+ & :focus {
88+ outline-offset : $rct-checkbox-outline-offset ;
89+ }
6290 }
6391
64- & .rct-native-display input {
65- margin : 0 5px ;
92+ & :not (.rct-native-display ) input {
93+ // Hide the native checkbox (but keep in accessibility tree and accessible via touch)
94+ position : absolute ;
95+ opacity : 0 ;
96+
97+ // Show focus effect on pseudo-checkbox
98+ & :focus {
99+ + .rct-checkbox {
100+ outline : $rct-outline-size solid $rct-outline-color ;
101+ outline-offset : $rct-outline-offset ;
102+ border-radius : $rct-outline-radius ;
103+ }
104+
105+ & :not (:focus-visible ) + .rct-checkbox {
106+ outline : none ;
107+ }
108+ }
66109 }
67110
68111 .rct-icon {
0 commit comments