Skip to content

Commit 77a7aa8

Browse files
authored
fix: icons disappear in Windows High Contrast Mode (#1150)
1 parent cb040c4 commit 77a7aa8

File tree

6 files changed

+90
-2
lines changed

6 files changed

+90
-2
lines changed

app/assets/main.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,26 @@
171171
}
172172
}
173173

174+
/*
175+
* Forced Colors Mode (WHCM) Override for Icons
176+
*
177+
* By default, `forced-color-adjust: preserve-parent-color` (from UnoConfig) works fine
178+
* for most icons as they inherit the correct text color.
179+
*
180+
* However, if icons disappear in specific contexts (e.g., inside buttons with
181+
* complex backgrounds or transparent states), uncomment the following block
182+
* to enforce visibility using `CanvasText`.
183+
*/
184+
/*
185+
@media (forced-colors: active) {
186+
[class^='i-'],
187+
[class*=' i-'] {
188+
forced-color-adjust: none !important;
189+
color: CanvasText !important;
190+
}
191+
}
192+
*/
193+
174194
html {
175195
-webkit-font-smoothing: antialiased;
176196
-moz-osx-font-smoothing: grayscale;

app/components/Settings/AccentColorPicker.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,18 @@ onPrehydrate(el => {
5959
</label>
6060
</fieldset>
6161
</template>
62+
63+
<style scoped>
64+
@media (forced-colors: active) {
65+
/* keep accent radio swatches visible in forced colors. */
66+
label {
67+
forced-color-adjust: none;
68+
border: 1px solid CanvasText;
69+
70+
&:has(> input:checked) {
71+
outline: 2px solid Highlight;
72+
outline-offset: 2px;
73+
}
74+
}
75+
}
76+
</style>

app/components/Settings/BgThemePicker.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,18 @@ onPrehydrate(el => {
3737
</label>
3838
</fieldset>
3939
</template>
40+
41+
<style scoped>
42+
@media (forced-colors: active) {
43+
/* keep background theme swatches visible in forced colors. */
44+
label {
45+
forced-color-adjust: none;
46+
border: 1px solid CanvasText;
47+
48+
&:has(> input:checked) {
49+
outline: 2px solid Highlight;
50+
outline-offset: 2px;
51+
}
52+
}
53+
}
54+
</style>

app/components/Settings/Toggle.client.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,31 @@ button[aria-checked='true'] > span:last-of-type > span {
5151
html[dir='rtl'] button[aria-checked='true'] > span:last-of-type > span {
5252
translate: calc(-100%);
5353
}
54+
55+
@media (forced-colors: active) {
56+
/* make toggle tracks and thumb visible in forced colors. */
57+
button[role='switch'] {
58+
& > span:last-of-type {
59+
forced-color-adjust: none;
60+
}
61+
62+
&[aria-checked='false'] > span:last-of-type {
63+
background: Canvas;
64+
border-color: CanvasText;
65+
66+
& > span {
67+
background: CanvasText;
68+
}
69+
}
70+
71+
&[aria-checked='true'] > span:last-of-type {
72+
background: Highlight;
73+
border-color: Highlight;
74+
75+
& > span {
76+
background: HighlightText;
77+
}
78+
}
79+
}
80+
}
5481
</style>

app/pages/index.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ defineOgImageComponent('Default', {
123123
<li v-for="framework in SHOWCASED_FRAMEWORKS" :key="framework.name">
124124
<LinkBase :to="packageRoute(framework.package)" class="gap-2 text-sm">
125125
<span
126-
class="w-1 h-1 rounded-full bg-accent group-hover:bg-fg transition-colors duration-200"
126+
class="home-tag-dot w-1 h-1 rounded-full bg-accent group-hover:bg-fg transition-colors duration-200"
127127
/>
128128
{{ framework.name }}
129129
</LinkBase>
@@ -139,3 +139,13 @@ defineOgImageComponent('Default', {
139139
</section>
140140
</main>
141141
</template>
142+
143+
<style scoped>
144+
/* Windows High Contrast Mode support */
145+
@media (forced-colors: active) {
146+
.home-tag-dot {
147+
forced-color-adjust: none;
148+
background-color: CanvasText;
149+
}
150+
}
151+
</style>

uno.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export default defineConfig({
2222
presetWind4(),
2323
presetIcons({
2424
extraProperties: {
25-
display: 'inline-block',
25+
'display': 'inline-block',
26+
'forced-color-adjust': 'preserve-parent-color',
2627
},
2728
warn: true,
2829
scale: 1.2,

0 commit comments

Comments
 (0)