Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically update theme when system theme changes #694

Open
uday-rana opened this issue Oct 4, 2024 · 3 comments
Open

Automatically update theme when system theme changes #694

uday-rana opened this issue Oct 4, 2024 · 3 comments

Comments

@uday-rana
Copy link

uday-rana commented Oct 4, 2024

It'd be nice to automatically set light or dark mode on initial load based on system theme. One way to do this might be using the CSS media feature prefers-color-scheme.

@humphd
Copy link
Collaborator

humphd commented Oct 4, 2024

We use Chakra UI, and its theming config works like this:

https://v2.chakra-ui.com/docs/styled-system/theme#config

Here is how the code is implemented

https://github.com/tarasglek/chatcraft.org/blob/main/src/theme.ts

@kliu57
Copy link
Collaborator

kliu57 commented Oct 18, 2024

It'd be nice to automatically set light or dark mode on initial load based on system theme. One way to do this might be using the CSS media feature prefers-color-scheme.

FYI
I did some testing on this and it seems when it comes to Chrome on desktop, Chatcraft will go with the Windows theme instead of the Chrome browser theme. As for mobile Chrome, Chatcraft will go with the browser's theme (you may need to refresh cache). For firefox, Chatcraft goes with the browser's theme (you may need to refresh cache).

Seems to me the functionality is already implemented.

@uday-rana
Copy link
Author

uday-rana commented Oct 18, 2024

You're right - I assumed it doesn't because the theme doesn't update when the system theme changes, even after reloading, which is really the issue I was trying to get at.

From what I understand, turning this on would just require changing useSystemColorMode from false to true in src/theme.ts.

@uday-rana uday-rana changed the title Automatically detect system theme Automatically update theme when system theme changes Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants