summaryrefslogtreecommitdiffstats
path: root/toolkit/themes/shared/checkbox.css
blob: 725c995a4d413bdc54b6071b704b175e430e3a0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/1999/xhtml");

checkbox {
  appearance: none;
  align-items: center;
  margin: 4px 2px;
}

.checkbox-icon[src] {
  margin-inline-end: 2px;
}

.checkbox-label {
  margin: 1px 0;
}

/* ..... disabled state ..... */

checkbox[disabled="true"] {
  opacity: 0.4;
}

/* ::::: checkmark image ::::: */

.checkbox-check {
  appearance: none;
  color: var(--checkbox-border-color, ThreeDShadow);
  background-color: var(--checkbox-unchecked-bgcolor, Field);
  border: 1px solid currentColor;
  border-radius: 2px;
  margin-inline-end: 6px;
}

.checkbox-check:not([native]) {
  height: 16px;
  width: 16px;
}

checkbox:not([disabled="true"]):hover > .checkbox-check {
  background-color: var(--checkbox-unchecked-hover-bgcolor, color-mix(in srgb, AccentColor 4%, Field));
}

checkbox:not([disabled="true"]):hover:active > .checkbox-check {
  background-color: var(--checkbox-unchecked-active-bgcolor, color-mix(in srgb, AccentColor 8%, Field));
}

.checkbox-check[checked] {
  border-color: var(--checkbox-checked-border-color, transparent);
  background-color: var(--checkbox-checked-bgcolor, AccentColor);
  background-image: url("chrome://global/skin/icons/check.svg");
  background-position: center;
  background-repeat: no-repeat;
  -moz-context-properties: fill;
  fill: currentColor;
  color: var(--checkbox-checked-color, AccentColorText);
  /* Style the button also when printing with "Print Backgrounds" unchecked */
  color-adjust: exact;
}

checkbox:not([disabled="true"]):hover > .checkbox-check[checked] {
  background-color: var(--checkbox-checked-hover-bgcolor, color-mix(in srgb, currentColor 12.5%, AccentColor));
}

checkbox:not([disabled="true"]):hover:active > .checkbox-check[checked] {
  background-color: var(--checkbox-checked-active-bgcolor, color-mix(in srgb, currentColor 25%, AccentColor));
}

checkbox:not([native]):focus-visible > .checkbox-check {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

@media (prefers-contrast) {
  checkbox:not([disabled="true"]):hover > .checkbox-check {
    /* color will set the border-color on the check due to how HCM works for in-content pages. */
    color: var(--checkbox-checked-border-color, color-mix(in srgb, AccentColor 4%, Field));
  }

  checkbox:not([disabled="true"]):hover:active > .checkbox-check[checked],
  checkbox:not([disabled="true"]):hover > .checkbox-check[checked] {
    color: var(--checkbox-checked-border-color, AccentColorText);
    fill: var(--checkbox-checked-color, AccentColorText);
    background-color: var(--checkbox-checked-bgcolor, AccentColor);
  }
}

/* ..... Platform overrides ..... */

@media (-moz-platform: windows) {
  checkbox:where([native]) {
    appearance: auto;
    -moz-default-appearance: checkbox-container;
    align-items: center;
    margin: 2px 4px;
    padding-top: 1px;
    padding-bottom: 1px;
    padding-inline-start: 4px;
    padding-inline-end: 2px;
  }

  .checkbox-label[native] {
    margin: 0;
  }

  /* ..... focused state ..... */

  checkbox[native]:focus-visible > .checkbox-label-box {
    outline: var(--focus-outline);
  }

  /* ..... disabled state ..... */

  checkbox[native][disabled="true"] {
    color: GrayText;
  }

  @media (-moz-windows-classic) {
    checkbox[native][disabled="true"] {
      color: ThreeDShadow;
      text-shadow: 1px 1px ThreeDHighlight;
    }
  }

  /* ::::: checkmark image ::::: */

  .checkbox-check[native] {
    appearance: auto;
    -moz-default-appearance: checkbox;
    align-items: center;
    margin-inline-end: 5px;
  }
}

@media (-moz-platform: macos) {
  checkbox:where([native]) {
    appearance: auto;
    -moz-default-appearance: checkbox-container;
    align-items: center;
    margin: 4px 2px;
  }

  .checkbox-label[native] {
    margin: 1px 0;
  }

  /* ..... disabled state ..... */

  checkbox[native][disabled="true"] {
    color: GrayText;
  }

  /* ::::: checkmark image ::::: */

  .checkbox-check[native] {
    appearance: auto;
    -moz-default-appearance: checkbox;
    margin-block: 1px 0;
    margin-inline: 1px 3px;
    /* vertical-align tells native theming where to snap to. However, this doesn't
     * always work reliably because of bug 503833. */
    vertical-align: top;
    width: 1.3em;
    height: 1.3em;
  }
}

@media (-moz-platform: linux) {
  checkbox:where([native]) {
    appearance: auto;
    -moz-default-appearance: checkbox-container;
    align-items: center;
    margin: 2px 4px;
  }

  .checkbox-label-box[native] {
    appearance: auto;
    -moz-default-appearance: checkbox-label;
  }

  .checkbox-label[native] {
    margin: 0;
  }

  /* ..... focused state ..... */

  checkbox[native]:focus-visible > .checkbox-label-box {
    /* Native theming should take care of this but it appears to be broken with
       some Gtk themes. Bug 1312169. */
    outline: var(--focus-outline);
  }

  /* ..... disabled state ..... */

  checkbox[native][disabled="true"] {
    color: GrayText;
  }

  /* ::::: checkmark image ::::: */

  .checkbox-check[native] {
    appearance: auto;
    -moz-default-appearance: checkbox;
    margin: 2px;
    margin-inline-end: 4px;
  }
}