vite-pwa / docs

Documentation: PWA integrations for Vite and the ecosystem
https://vite-pwa-org.netlify.app/
MIT License
196 stars 42 forks source link

Change background color of maskable icons #95

Closed ido-pluto closed 8 months ago

ido-pluto commented 8 months ago

Is there a way to change the background colour of the maskable-icon and apple-touch-icon files?

After installing the PWA app you can see a white background in the installed app's icon

image

userquin commented 8 months ago

Check the webmanifest theme_color , should match the same color in html head meta theme-color, check:

If previous configuration doesn't work, you can use @vite-pwa/assets-generator to create the icons and change the bg color for the maskable pwa assets: https://vite-pwa-org.netlify.app/assets-generator/cli.html

ido-pluto commented 8 months ago

Thank you! That works.

I needed to change the preset in pwa-assets.config.ts to have:

    maskable: {
        resizeOptions: {
            background: '#000'
        }
    },

It would be best if it would check the index.html or the pwa config in vite.config.ts for that colour

For feature reference: https://vite-pwa-org.netlify.app/assets-generator/cli.html#ios-ipad-splash-screens

userquin commented 8 months ago

It would be best if it would check the index.html or the pwa config in vite.config.ts for that colour

Not all (meta)frameworks support html entry point (for example Nuxt 3/Astro) and another ones can use another entry point name (app.html in Sveltekit).

The assets generator is framework agnostic, you can create a common module in your app with the PWA configuration and use it in the vite config file and inside the assets generator configuration to access theme color info.

schwartzman commented 4 months ago

Would be super amazing to actually include this in the documentation...