Skip to main contentSkip to docs navigation

Chassis

Icon Assets

View on GitHub

Where the icons of an app go in the source, which formats each platform keeps, and how the build names them for web, iOS and Android.

Introduction

Icons are the files under icons/ of an app: the icons of the interface, one file per icon.

The web output gets every file of the folder. iOS gets the SVG, PDF and PNG files, and Android gets the SVG files, each with the ic_ prefix. The build copies an icon as it is. With the --icon-catalog option it writes the icons of iOS as an asset catalog, and with --vector-drawables it writes the SVG icons of Android as vector drawables.

Source layout

Icons live in source/<brand>/<app>/icons/, in any subfolders. The build keeps the subfolders in the output of every platform.

TEXT
source/
├── _default/
│   └── <app>/
│       └── icons/
│           ├── arrow-right-outline.svg
│           ├── arrow-right-solid.svg
│           └── loyalty-card.svg
└── <brand>/
    └── <app>/
        └── icons/
            └── loyalty-card.svg        -> replaces the default file of the same path

An icon of the default brand is the icon of every brand. A brand file replaces the default file of the same path, so a brand holds only the icons it draws differently, and an icon that only a brand holds is in the output of that brand only. Each app holds the icons it shows, and the icons that every app of a brand shows go under the shared folder, source/<brand>/_shared/icons/.

Formats

Each platform keeps the formats it can use, and the build leaves the rest out.

FormatWebiOSAndroid
SVGCopiedCopiedCopied
PDF, PNGCopiedCopiedDropped
Any other formatCopiedDroppedDropped

An SVG icon drawn in one color, currentcolor, takes the color of the text on the web and the tint of its view in an app. An Android app draws an icon from a vector drawable: a build with --vector-drawables writes one per SVG file, and Vector Asset Studio of Android Studio makes one from a single file.

Naming

An icon is named after what it shows, in lowercase with hyphens, followed by its style when the icons come in styles: arrow-right-solid.svg, arrow-right-outline.svg. A brand that draws an icon differently keeps its name, so that an app refers to arrow-right-solid whichever brand it is built for.

The build renames each file for the platform: kebab-case for the web, snake_case for iOS and Android.

On Android the build also adds the ic_ prefix to every file under icons/, unless the name starts with it already, so arrow-right-solid.svg is ic_arrow_right_solid.svg.

Adding files

Export each icon as SVG from the design tool, with the name the app reads, and put it under icons/ of the app that shows it. Run the build.

Shell
cp loyalty-card.svg source/_default/mobile/icons/
npx chassis-assets build

Best practices

These practices keep each icon in one place and its name stable across brands and platforms.

  • Keep the icon names across brands: an app that shows arrow-right-solid gets the drawing of the brand it is built for. A brand that renames an icon needs a change in every app.
  • Draw icons in currentcolor: the app colors the icon, so one file serves every theme and state.
  • Compare dist/ when icons change: an icon that is gone breaks an app that reads it by name.

Avoid the habits that undo this:

  • Do not put other images under icons/: Android adds the ic_ prefix to every file of the folder, and the apps get only the formats of the table above. A logo or an illustration belongs under images/.
  • Do not put the app icon under icons/: it is a bundle in a folder of its own, such as app-icon/, see app icons.

Platform output

The build copies each file to the icons/ folder of the job, in its subfolder, and renames it for the platform.

PlatformFolderNameFormats
Webdist/web/<app>/<brand>/icons/kebab-caseEvery format
iOSdist/ios/<app>/<brand>/icons/snake_caseSVG, PDF, PNG
Androiddist/android/<app>/<brand>/icons/snake_case with the ic_ prefixSVG

The web output keeps every file, in its subfolder:

TEXT
dist/web/<app>/<brand>/icons/
├── arrow-right-outline.svg
├── arrow-right-solid.svg
└── loyalty-card.svg

The iOS output holds the SVG files in snake_case:

TEXT
dist/ios/<app>/<brand>/icons/
├── arrow_right_outline.svg
├── arrow_right_solid.svg
└── loyalty_card.svg

The Android output holds the same files with the prefix:

TEXT
dist/android/<app>/<brand>/icons/
├── ic_arrow_right_outline.svg
├── ic_arrow_right_solid.svg
└── ic_loyalty_card.svg

A build with chassis-assets build --vector-drawables writes each of these SVG files as a vector drawable of the same name. An SVG file with no shape to draw stays an SVG, and the build warns about it:

TEXT
dist/android/<app>/<brand>/icons/
├── ic_arrow_right_outline.xml
├── ic_arrow_right_solid.xml
└── ic_loyalty_card.xml

A build with chassis-assets build --icon-catalog writes the icons of iOS as image sets of Icons.xcassets, such as Icons.xcassets/arrow_right_solid.imageset/.

See the web, iOS, and Android docs for how an app uses these files.