1 @import "mediawiki.mixins";
2 @import "mediawiki.ui/variables";
6 // Styling checkboxes in a way that works cross browser is a tricky problem to solve.
7 // In MediaWiki UI put a checkbox and label inside a mw-ui-checkbox div.
8 // This renders in all browsers except IE6-8 which do not support the :checked selector;
9 // these are kept backwards-compatible using the :not(#noop) selector.
10 // You should give the checkbox and label matching "id" and "for" attributes, respectively.
13 // <div class="mw-ui-checkbox">
14 // <input type="checkbox" id="kss-example-3">
15 // <label for="kss-example-3">Standard checkbox</label>
17 // <div class="mw-ui-checkbox">
18 // <input type="checkbox" id="kss-example-3-checked" checked>
19 // <label for="kss-example-3-checked">Standard checked checkbox</label>
21 // <div class="mw-ui-checkbox">
22 // <input type="checkbox" id="kss-example-3-disabled" disabled>
23 // <label for="kss-example-3-disabled">Disabled checkbox</label>
25 // <div class="mw-ui-checkbox">
26 // <input type="checkbox" id="kss-example-3-disabled-checked" disabled checked>
27 // <label for="kss-example-3-disabled-checked">Disabled checked checkbox</label>
32 display: inline-block;
33 vertical-align: middle;
38 // We use the not selector to cancel out styling on IE 8 and below
39 .mw-ui-checkbox:not(#noop) {
40 // Position relatively so we can make use of absolute pseudo elements
42 line-height: @checkboxSize;
45 // reset font sizes (see bug 72727)
47 vertical-align: middle;
50 input[type="checkbox"] {
51 // we hide the input element as instead we will style the label that follows
52 // we use opacity so that VoiceOver software can still identify it
54 // ensure the invisible checkbox takes up the required width
56 height: @checkboxSize;
57 // This is needed for Firefox mobile (See bug 71750 to workaround default Firefox stylesheet)
62 // the pseudo before element of the label after the checkbox now looks like a checkbox
64 .transition( 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) );
67 .box-sizing(border-box);
70 border-radius: @borderRadius;
72 height: @checkboxSize;
73 background-color: #fff;
74 border: 1px solid @colorGray7;
75 .background-image-svg('images/checked.svg', 'images/checked.png');
76 .background-size( @checkboxSize - 0.2em, @checkboxSize - 0.2em );
77 background-repeat: no-repeat;
78 background-position: center center;
79 background-origin: border-box;
83 // when the input is checked, style the label pseudo before element that followed as a checked checkbox
84 &:checked + label::before {
85 background-size: 100% 100%;
88 &:active + label::before {
89 background-color: @colorGray13;
90 border-color: @colorGray13;
93 &:focus + label::before {
97 &:focus:hover + label::before,
98 &:hover + label::before {
99 border-bottom-width: 3px;
102 // disabled checkboxes have a gray background
103 &:disabled + label::before {
105 background-color: @colorGray14;
106 border-color: @colorGray14;
109 // disabled and checked checkboxes have a white circle
110 &:disabled:checked + label::before {
111 .background-image-svg('images/checked_disabled.svg', 'images/checked_disabled.png');