Tableau UI for Angular

Icons

An icon shows a Material Symbols icon by its name, in the style, weight and fill the app picks.

Import

Import TableauUiIconModule from tableau-ui-angular/icon, for tab-icon.

An icon

  • value is the icon's name on Google Fonts' Material Symbols page, such as home.
  • label names an icon that means something alone, such as the only content of a button. Without one, an icon is decorative, and hidden from screen readers.
  • An icon is 1.2 times the font size around it, so the font sizes it; fontSize gives it a size of its own.
  • color is primary, success or error, the theme's colours; the CSS color gives any other.

Home, sized by the text

A larger font, a larger icon

A size of its own, from fontSize

The theme's primary, success and error colours, and a CSS colour

Searches: 0

import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { TableauUiButtonModule } from 'tableau-ui-angular/button';
import { TableauUiIconModule } from 'tableau-ui-angular/icon';

@Component({
  selector: 'app-icon-basic-example',
  imports: [TableauUiButtonModule, TableauUiIconModule],
  templateUrl: './icon-basic.example.html',
  styleUrl: './icon-basic.example.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconBasicExampleComponent {
  protected readonly $searches = signal(0);
}

Style

The inputs pick the icon's font and its variable axes. An app that downloads its icons lists each one it uses, below.

InputValues
typeMaterial Symbols Rounded, the default, Material Symbols Outlined or Material Symbols Sharp
[fill]true fills the icon; false by default
[weight]100 to 700, in hundreds; 400 by default
[grade]-25, 0, the default, or 200
[opticalSizePx]20, 24, the default, 40 or 48
[params]Any of them, with color and fontSize, in one object; each one it sets wins over its own input
Material Symbols Rounded
Material Symbols Outlined
Material Symbols Sharp
Filled
Weight 100
Weight 400
Weight 700
Grade -25
Grade 0
Grade 200
Optical size 20
Optical size 24
Optical size 40
Optical size 48
Each input
The same, from params
import { ChangeDetectionStrategy, Component } from '@angular/core';
import type { IconParams } from 'tableau-ui-angular/icon';
import { TableauUiIconModule } from 'tableau-ui-angular/icon';

@Component({
  selector: 'app-icon-style-example',
  imports: [TableauUiIconModule],
  templateUrl: './icon-style.example.html',
  styleUrl: './icon-style.example.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconStyleExampleComponent {
  protected readonly types = ['Material Symbols Rounded', 'Material Symbols Outlined', 'Material Symbols Sharp'] as const;
  protected readonly weights = [100, 400, 700] as const;
  protected readonly grades = [-25, 0, 200] as const;
  protected readonly opticalSizes = [20, 24, 40, 48] as const;

  // Every parameter at once; each one it sets wins over its own input
  protected readonly params: IconParams = { color: 'primary', type: 'Material Symbols Outlined', fill: true, weight: 100, grade: 200, opticalSizePx: 48 };
}

Loading the icons

The app loads the icons' fonts in its styles.scss, in one of two ways; this site uses the script.

WayWhat the browser downloadsWhat the app keeps
The used-icons scriptOnly the icons the app lists, in the styles it lists: kilobytesThe list, in src/icons.ts
The material-symbols packageEvery icon, in every weight, grade, optical size and fill: several megabytes per styleNothing

The used-icons script

The script ships with the package. It compiles the list with the app's own typescript, which an Angular app has, and downloads the icons' fonts and their CSS into a folder of the app.

  1. List the icons in src/icons.ts, in a class named Icons, which the script reads, that extends UsedIcons from tableau-ui-angular/used-icons. With the library's own, this list downloads 17 icons in 2 fonts.
import { UsedIcons } from 'tableau-ui-angular/used-icons';

// The icons the app uses, by their Material Symbols name, and the styles it shows them in
export class Icons extends UsedIcons {
  // Each list is optional: without it, the script downloads the style tab-icon shows by default
  override fonts: ('Material Symbols Outlined' | 'Material Symbols Rounded' | 'Material Symbols Sharp')[] = ['Material Symbols Rounded', 'Material Symbols Outlined'];
  // Several numbers download the range from the lowest to the highest: here every weight from 100 to 700
  override weights: (100 | 200 | 300 | 400 | 500 | 600 | 700)[] = [100, 700];
  override grades: (-25 | 0 | 200)[] = [0, 200];
  override opticalSizes: (20 | 24 | 40 | 48)[] = [24, 48];
  override fills: boolean[] = [false, true];

  override usedIcons: string[] = ['add_circle', 'do_not_disturb_on', 'home', 'palette', 'search'];
}
  1. Run the script from the app's package.json: prebuild runs it before npm run build, and icons:watch runs it again whenever src/icons.ts changes, while npm start serves the app.
{
  "scripts": {
    "icons": "node node_modules/tableau-ui-angular/used-icons/scripts/update-icons.js src/icons.ts public/icons",
    "prebuild": "npm run icons",
    "icons:watch": "npm run icons && chokidar src/icons.ts -c \"npm run icons\"",
    "start": "concurrently \"ng serve\" \"npm run icons:watch\""
  }
}

The watch and the start use two dev tools:

npm install --save-dev chokidar-cli concurrently
  1. Use the CSS the script writes, material-icons.css, in styles.scss:
@use '../public/icons/material-icons.css';

The script asks Google Fonts' CSS API, https://fonts.googleapis.com/css2; set another URL, such as a mirror's, in TABLEAU_UI_ICONS_CSS_URL. Behind a proxy, Node's fetch, which the script downloads with, uses HTTPS_PROXY only when NODE_USE_ENV_PROXY=1 is set too.

The material-symbols package

Install the package:

npm install material-symbols

Then use, in styles.scss, each style the app's icons show in: rounded for the default type, outlined and sharp for the others.

@use 'material-symbols/rounded';
@use 'material-symbols/outlined';
@use 'material-symbols/sharp';