Skip to content

Commit d90570c

Browse files
committed
1 parent 2257ead commit d90570c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/useIsDark/client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ export function startClientSideIsDarkLogic(params: {
109109
trustedTypesPolicyName
110110
} = params;
111111

112+
reset_user_preference: {
113+
const localStorageKey = "scheme-default";
114+
115+
const localStorageValue = localStorage.getItem(localStorageKey);
116+
117+
if (localStorageValue === colorSchemeExplicitlyProvidedAsParameter) {
118+
break reset_user_preference;
119+
}
120+
121+
localStorage.removeItem("scheme");
122+
123+
localStorage.setItem(localStorageKey, colorSchemeExplicitlyProvidedAsParameter);
124+
}
125+
112126
const { clientSideIsDark, ssrWasPerformedWithIsDark: ssrWasPerformedWithIsDark_ } = ((): {
113127
clientSideIsDark: boolean;
114128
ssrWasPerformedWithIsDark: boolean;

0 commit comments

Comments
 (0)