Skip to main contentSkip to docs navigation

Chassis

Welcome to Chassis Icons

View on GitHub

Chassis Icons is the builder of icon sets. The chassis-icons command turns a repository of SVG files into an icon font, an SVG sprite and optimized SVG files.

Introduction

Chassis Icons turns the SVG files of a team into an icon font, an SVG sprite and optimized SVG files. The work is split over two kinds of repository, so that a team owns its icons and shares the build:

  • The builder. @chassis-ui/icons is an npm package with the chassis-icons command, which optimizes the files with SVGO, builds the sprite with svg-sprite and the font with Fantasticon, and writes the stylesheets of the font. For a set whose targets name ios and android, it also writes an asset catalog with a Swift file, and vector drawables. It holds no icons.
  • A repository of icons. It holds the SVG files in source/, one per icon, the chassis.build block of its package.json, and the registry of the code points. The output is built from them and not committed: the release of the repository builds and publishes it. chassis-icons init writes one, and the builder is a development dependency of it.

The build is file-driven. Save <name>.svg into source/, and the icon is in the output of the next build: there is no list to maintain beside the files. The font name, the class prefix, the frame and the styles of the icons are settings of chassis.build, so the same build writes the set of any team, as Chassis Tokens builds the tokens of any team.

These pages document the builder, and show no set. Their examples are of the team Acme: the quick start makes @acme/icons, and the pages of Use in Project draw the icons of @acme/glyphs, a set with the font acme-glyphs, the prefix ag and a frame of 16. The quick start makes a repository of your own; the pages of Icon Design say what a file needs to be an icon of a set, and those of Use in Project how a page draws an icon from the output.

What a set is

A set is the icons of one repository: the SVG files of source/, and what the build writes from them. One repository builds one set, and chassis-icons init writes the files around them.

TEXT
source/                   -> The SVG files you save, one per icon. The build only reads them
package.json              -> The details of the package and the chassis.build configuration
dist/                     -> Output: not committed. The release of the set builds it again
  icons.json              -> The index of the set: its settings, and each icon with its code point
  svgs/                   -> One optimized SVG file per icon
  web/                    -> The font, its stylesheets and the sprite
  ios/                    -> With the ios target: the asset catalog and the Swift file
  android/                -> With the android target: the vector drawables
codepoints.json           -> The code point of each icon. Written by the build, and committed
README.md                 -> Written by the build, and committed, for someone who installs the set
chassis.checks.json       -> The icons that consumers of the set read by name, when it has one
preview/                  -> The page of the set, written by chassis-icons preview. Not committed

The name of a file is the name of its icon, and that name is everything a project needs to draw the icon: it is the symbol of the sprite, the last part of the class of the font, and the name of the optimized file.

What the build writes

The build writes one folder, dist/, and its shape is the same for any set. The web is always built, and chassis.build.targets adds the folders of iOS and Android. <font> is the font name of the configuration, <prefix> its class prefix, and <name> the name of an icon.

FileWhat it holds
dist/icons.jsonThe index of the set: the font name, the prefix, the frame and the styles, and each icon with its code point and its style
dist/svgs/<name>.svgOne icon, optimized, on the frame, with fill="currentcolor"
dist/web/<font>.svgThe sprite: one <symbol> per icon, with the id <name>
dist/web/<font>.woff2 and the other formatsThe icon font
dist/web/<font>.css, dist/web/<font>.min.cssThe font face and one class per icon, <prefix>-<name>
dist/web/<font>.scssThe same for Sass, with the folder of the font and the map of the icons as variables
dist/web/<font>.jsonThe code point of each icon, by name
dist/ios/<module>.xcassets, dist/ios/<module>.swiftWith the ios target: an image set per icon, and the enum of the icons. <module> is the font name in PascalCase
dist/android/res/drawable/<prefix>_<name>.xmlWith the android target: a vector drawable per icon

The repository of icons does not commit the output: its release builds it, publishes the files of the web as a package, and attaches the archives of the web and of each target to its GitHub release, so a project installs the set without building it. The pages of Use in Project show how a page draws an icon from each of these files.

What reads a set

Chassis CSS, Chassis React and the apps of iOS and Android take any set that keeps this shape, and a team points each of them at its own set.

ConsumerWhat it readsPage
Chassis CSSAn SVG file by name, through svg-icon()Chassis CSS
Chassis ReactA symbol of the sprite, or a class of the font, through IconChassis React
An iOS or Android appThe files of dist/ios/ and dist/android/, from the archives of a releaseiOS and Android

Next steps

Continue with one of these pages:

  • Quick start: make a repository of icons, build it and release it.
  • Build system: the commands, the configuration and the checks.
  • Frame and color: what an SVG file needs to be an icon of a set.