Skip to content

Commit 9108ed3

Browse files
committed
fix(ui): default data-theme on SSR
1 parent bf0c8f7 commit 9108ed3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/app.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ useHead({
3636
'lang': () => locale.value,
3737
'dir': () => localeMap[locale.value] ?? 'ltr',
3838
'data-kbd-hints': () => showKbdHints.value,
39+
/**
40+
* npmx default theme is dark. But on initial load we don't know the user's preference yet.
41+
* Without this attribute being set here, no theme gets loaded, regardless of user's preference,
42+
* and a white page flashes before the correct theme is applied. Setting it to 'light' here
43+
* doesn't prevent the flash of white page for dark mode users, but at least the page doesn't
44+
* look broken while loading and white mode users get the correct theme immediately.
45+
*/
46+
'data-theme': () => 'light',
3947
},
4048
titleTemplate: titleChunk => {
4149
return titleChunk ? titleChunk : 'npmx - Better npm Package Browser'

0 commit comments

Comments
 (0)