diff --git a/js/src/common/components/Checkbox.js b/js/src/common/components/Checkbox.js
index 47f0f7e0e2..5c86ba2700 100644
--- a/js/src/common/components/Checkbox.js
+++ b/js/src/common/components/Checkbox.js
@@ -33,7 +33,9 @@ export default class Checkbox extends Component {
return (
);
diff --git a/less/common/Checkbox.less b/less/common/Checkbox.less
index a7dbac58b5..7826e28c53 100644
--- a/less/common/Checkbox.less
+++ b/less/common/Checkbox.less
@@ -2,18 +2,42 @@
display: block;
cursor: pointer;
margin: 0;
+ position: relative;
+
+ input[type="checkbox"] {
+ position: absolute;
+ z-index: 1;
+
+ opacity: 0;
+
+ top: 0;
+ bottom: 0;
+ left: 0;
+ right: 0;
- & input[type="checkbox"] {
- display: none;
+ width: 100%;
+ height: 100%;
+
+ cursor: pointer;
+
+ .add-keyboard-focus-ring-nearby("+ .Checkbox-display");
}
}
.Checkbox--switch {
- padding-left: 65px;
+ @left-pad: 65px;
+
+ padding-left: @left-pad;
margin: 5px 0;
+ input[type="checkbox"] {
+ top: -4px;
+ width: 50px;
+ height: 28px;
+ }
+
.Checkbox-display {
float: left;
- margin-left: -65px;
+ margin-left: -@left-pad;
margin-top: -4px;
}
}
diff --git a/less/common/mixins/accessibility.less b/less/common/mixins/accessibility.less
index cf35f08f96..db261852d0 100644
--- a/less/common/mixins/accessibility.less
+++ b/less/common/mixins/accessibility.less
@@ -39,13 +39,13 @@
*
* For example...
*
- *? button { .addKeyboardFocusRing(":focus-within") }
+ *? button { .add-keyboard-focus-ring(":focus-within") }
* becomes
*? button:focus-within { }
*
* AND
*
- *? button { .addKeyboardFocusRing(" :focus-within") }
+ *? button { .add-keyboard-focus-ring(" :focus-within") }
* becomes
*? button :focus-within { }
*/
@@ -57,6 +57,38 @@
}
}
+/**
+ * This mixin allows support for a custom element nearby the focused one
+ * to have a focus style applied to it
+ *
+ * For example...
+ *
+ *? button { .add-keyboard-focus-ring-nearby("+ .myOtherElement") }
+ * becomes
+ *? button:-moz-focusring + .myOtherElement { }
+ *? button:focus-within + .myOtherElement { }
+ */
+.add-keyboard-focus-ring-nearby(@nearbySelector) {
+ @realNearbySelector: ~"@{nearbySelector}";
+
+ // We need to declare these separately, otherwise
+ // browsers will ignore `:focus-visible` as they
+ // don't understand `:-moz-focusring`
+
+ // These are the keyboard-only versions of :focus
+ &:-moz-focusring {
+ @{realNearbySelector} {
+ #private.__focus-ring-styles();
+ }
+ }
+
+ &:focus-visible {
+ @{realNearbySelector} {
+ #private.__focus-ring-styles();
+ }
+ }
+}
+
/**
* Allows an offset to be supplied for an a11y
* outline.
diff --git a/less/common/scaffolding.less b/less/common/scaffolding.less
index facfa6f432..2093d99ac3 100644
--- a/less/common/scaffolding.less
+++ b/less/common/scaffolding.less
@@ -159,3 +159,13 @@ blockquote ol:last-child {
font-size: 18px;
color: @muted-more-color;
}
+
+.visually-hidden {
+ clip: rect(0 0 0 0);
+ clip-path: inset(50%);
+ height: 1px;
+ overflow: hidden;
+ position: absolute;
+ white-space: nowrap;
+ width: 1px;
+}