How to set meta theme-color in nuxt.config
Why isn't theme_color or theme-color valid? What can I set here?
23 Replies
you need to define it as a regular meta tag, where the object's keys and values are the attribute names and values respectively. use this as reference
MDN Web Docs
theme-color - HTML: HyperText Markup Language | MDN
The theme-color value for the name attribute of the element indicates a suggested color that user agents should use to customize the display of the page or of the surrounding user interface. If specified, the content attribute must contain a valid CSS .
we're actually using this package apparently. That changes things I assume
https://nuxt.com/modules/vite-pwa-nuxt
you can check the manifest section in the application tab to see if the configuration is being deisplayed there. if it is, I'd assume vite-pwa-nuxt only injects the theme color when the app is installed
also, I don't know how you're testing the implementation, but it's easier using a Safari
I'm checking it in lighthouse Chrome
do you see something like this in there?
yes sorry for the delay it wasnt loading for some reason
cool.
follow up question: do you see a meta tag with the theme color injected in the DOM?
so it is actually working, its just lighthous eisnt detecting it?
means your pwa config is working fine
no its not in DOM
yeah. I don't vite-pwa-nuxt injects it in the DOM until the app has been installed
hm so I guess this is fine then. That issue i screenshotted is listed under PWA optimized
so not neccessary to be ticked off then
you can also add the theme color in the
app.head.meta
array of your nuxt.config.js
that should helpthat takes us back to the first post in the thread. theme-color and theme_color don't exist in the array
the definition is different there
just as you'd see in the mdn doc
ah i see, let me try that
gotcha
@pyplacca so whats that doing differently than setting in in PWA?
pretty much the same but in a different scenario
shouldnt it be changing my broswer colour or something then?
depends on what browser you're using
...and whether you're viewing on mobile or desktop
Safari does a better job at that
ok
sounds good
thanks for your help 🙂
happy to assist