-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Support for theme-color
#78
Comments
You can set <meta name="theme-color" content="var(--bg)"> If we were to add it to next-themes (and not use the CSS variable trick above), how we would determine which color to set? Maybe consumers could provide a |
Oh I didn’t know that it works with variables, then it almost solves my problem. If building this into the lib, I can see a
|
@pacocoursey Using the meta tag method you mentioned doesn't seem to be working in the latest Safari/iOS. I still need to refresh the page to see the browser theme change. I'm setting the css variable like this (I use class mode with Tailwind): html { --bg: white; }
html.dark { --bg: black; } Any suggestions? |
Facing the same thing myself. |
Since the CSS variable trick no longer seems to work, I'd recommend implementing this manually in your code with something like this: const { resolvedTheme } = useTheme();
return (
<Head>
<meta name="theme-color" value={resolvedTheme === 'dark' ? '#000' : '#fff'}
</Head>
) I plan to add this for v1 of next-themes though, and I like the API that @shuding suggested above! <ThemeProvider
themeColor={{ dark: '#000', light: '#fff' }}
// or
themeColor="var(--theme-color)" // vars must be on the same element as data-theme is applied, which right is now always html aka :root
// or
themeColor={{ dark: 'var(--dark-bg)', light: '#fff' }}
/> |
This is available in the v1 beta:
|
Hi @pacocoursey , when v1 release? like this feature. |
@pacocoursey v1 is not published on NPM. |
i solve this problem using this approach:
may this help! |
For Next.js 13 app router app/layout.tsx
components/toggle-theme.tsx
refer https://github.com/tailwindlabs/tailwindcss.com/blob/master/src/pages/_document.js#L31 |
Is a fix being worked on for this so we don’t need to add custom logic to ensure automatic color switching on Safari? |
@shawnlong636 Could you elaborate? Do you have the issue with the v1 branch? |
confirming this is working for me with the is there any plan to release that as a full version? happy to help test, it looks like the changes are fairly small |
Any timeline on when v1 will be released? |
This one did not make it to v0.3.0? 🤔 |
Planning to add this in v1, which is still upcoming. |
@pacocoursey Hi there! How to achieve the proposed |
@monecchi you can do something like this:
I'm using |
Thanks @spacecat! I'll give it a try! It seems the beta version I installed Also, thanks @NavOrange! I've tested your solution and it worked flawlessly! While developing a PWA with the Window Controls Overlay feature enabled in |
@spacecat yes, most likely it has got to do with the npm package version. |
Hi @pacocoursey , just following up on this issue as I'm currently upgrading all of my npm packages in my project. I was just wondering if you see this feature included in a stable release some time in the near future? Thanks! |
Safari 15 uses this meta tag to indicate the UI color of the address bar etc., and usually we need to switch it upon theme changes. The media query only works with the system preferences rather than per-site settings via next-themes, so it might be a good add-on for this lib to automatically update it.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color
The text was updated successfully, but these errors were encountered: