search
HomeWeb Front-endCSS TutorialMaskable Icons: Android Adaptive Icons for Your PWA

Android adaptive icons for Progressive Web App (PWA): Maskable Icons Guide

You have created a progressive web application (PWA) and designed the corresponding icon, which is now being installed on the Android home screen. However, if you are using a newer Android phone, your icon may display as follows:

Maskable Icons: Android Adaptive Icons for Your PWA

What's going on? Android Oreo introduces adaptive icons, a new icon format that forces all home screen icons to take the same shape. Icons that do not conform to the new format will be displayed as a white background.

However, a new web feature called maskable icons will be available in Firefox Preview and other web browsers soon. This new icon format will allow your PWA to have its own adaptive icons on Android.

I work in Mozilla and implement support for maskable icons in Firefox Preview. I'll show you how to add them to your own Android PWA.

What are maskable icons and adaptive icons?

A few years ago, Android app icons were in free form and could be any shape. This means that web apps can also reuse the same transparent icon when pinned to the home screen.

However, manufacturers like Samsung want to make all icons on the device have the same shape for consistency. Some manufacturers even want to use different shapes. To address various requirements for manufacturers and devices, Android introduced "adaptive icons". You provide an image with extra space around the edges, which Android will crop into the correct shape.

But web applications are designed to run on any platform, so they don't have an API to create these special Android icons. Instead, the icon will be squeezed into a white box like this:

It is gratifying that a brand new API appeared last September and was added to the W3C specification. Maskable icons allows web developers to specify a full bleeding icon that will be cropped. It is platform-agnostic, so Windows can use it for tile and iOS can use it for icons.

How to create maskable icons

Since the maskable icon format is designed to work with any platform, its size and scale are different from the size and scale of Android's adaptive icons. This means you cannot reuse the same resources.

Maskable icons can be any size, and you can continue to use the same size as a normal transparent icon. But when designing icons, make sure that important information is within the "Safe Area" circle with a radius equal to 40% of the image size.

Ensure that all pixels in this area are visible. Pixels outside the area may be cropped according to the icon shape and platform.

Warning: If you already have an Android app, avoid copying and pasting the icon from the Android app to the web app. The scales are different, so your icon looks too small.

Add icons to the web application manifest

After creating an icon, you can add an entry to the Web application manifest similar to other icon resources. The Web Application manifest provides information about the Web application in a JSON file and contains an "icons" array.

 <code>{ ... "icons": [ ... { "src": "path/to/maskable_icon.png", "sizes": "196x196", "type": "image/png", "purpose": "maskable" ] ... }</code>

Maskable icons use a special new key "purpose" to indicate that they are intended to be used with the icon mask. The default "purpose" for an icon with a transparent background is "any", and each option can be separated by spaces to use multiple uses for the icon.

 <code>"purpose": "maskable any"</code>

Preview your icon

Do you want to see what your own maskable icons look like? I created a tool Maskable.app to help you evaluate how the icon looks under different shapes.

The app allows you to preview icons in various shapes that can be found on Android devices. I hope this tool helps you create unique icons for progressive web applications.

[View application] [View source code]

Once you are satisfied with the results, you can start testing your application. Firefox Preview Nightly and Chrome Canary both support maskable icons. You can use them to see how your PWA looks.

Tools like PWACompat also support maskable icons. You can automatically generate icons for iOS and other devices based on the new maskable icons!

Start creating your own icons

If you want more control over how PWA icons appear on Android, maskable icons are your best choice. With maskable icons, you can customize the edge-to-edge display of icons. Hope this article helps you start creating the first maskable icon.

Icon source:

The above is the detailed content of Maskable Icons: Android Adaptive Icons for Your PWA. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
A Little Reminder That Pseudo Elements are Children, Kinda.A Little Reminder That Pseudo Elements are Children, Kinda.Apr 19, 2025 am 11:39 AM

Here's a container with some child elements:

Menus with 'Dynamic Hit Areas'Menus with 'Dynamic Hit Areas'Apr 19, 2025 am 11:37 AM

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

Improving Video Accessibility with WebVTTImproving Video Accessibility with WebVTTApr 19, 2025 am 11:27 AM

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

Weekly Platform News: CSS ::marker pseudo-element, pre-rendering web components, adding Webmention to your siteWeekly Platform News: CSS ::marker pseudo-element, pre-rendering web components, adding Webmention to your siteApr 19, 2025 am 11:25 AM

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

Making width and flexible items play nice togetherMaking width and flexible items play nice togetherApr 19, 2025 am 11:23 AM

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

Position Sticky and Table HeadersPosition Sticky and Table HeadersApr 19, 2025 am 11:21 AM

You can't position: sticky; a

Weekly Platform News: HTML Inspection in Search Console, Global Scope of Scripts, Babel env Adds defaults QueryWeekly Platform News: HTML Inspection in Search Console, Global Scope of Scripts, Babel env Adds defaults QueryApr 19, 2025 am 11:18 AM

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

IndieWeb and WebmentionsIndieWeb and WebmentionsApr 19, 2025 am 11:16 AM

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about it:

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment