Class MaterialIcon

  • MaterialIcon objects allow you to use and customize Google Font Icons within Google Workspace Add-ons and Google Chat apps.

  • You can customize the icon's appearance by setting its fill, grade, name, and weight using methods like setFill(), setGrade(), setName(), and setWeight().

  • Refer to the Google Font Icons website to preview different icon settings and find valid icon names.

  • When setting grade and weight, ensure you use the accepted values or the default values will be applied.

  • The setName() method is required and uses the icon name as defined on the Google Font Icons website; using an invalid name will result in the icon not rendering.

MaterialIcon

An object that supports all Google Font Icons.

Available for Google Workspace add-ons and Google Chat apps.

const materialIcon = CardService.newMaterialIcon()
                         .setName('search')
                         .setFill(true)
                         .setWeight(400)
                         .setGrade(0);

Methods

MethodReturn typeBrief description
setFill(fill)MaterialIconWhether the icon renders as filled.
setGrade(grade)MaterialIconWeight and grade affect a symbol’s thickness.
setName(name)MaterialIconSets the name of the icon.
setWeight(weight)MaterialIconThe stroke weight of the icon.

Detailed documentation

setFill(fill)

Whether the icon renders as filled. Default value is false.

To preview different icon settings, go to Google Font Icons and adjust the settings under Customize.

const materialIcon =
    CardService.newMaterialIcon().setName('search').setFill(true);

Parameters

NameTypeDescription
fillBooleanWhether the icon is filled.

Return

MaterialIcon — This object, for chaining.


setGrade(grade)

Weight and grade affect a symbol’s thickness. Adjustments to grade are more granular than adjustments to weight and have a small impact on the size of the symbol. Choose from {-25, 0, 200}. If absent, default value is 0. If any other value is specified, the default value is used.

To preview different icon settings, go to Google Font Icons and adjust the settings under Customize.

const materialIcon =
    CardService.newMaterialIcon().setName('search').setGrade(200);

Parameters

NameTypeDescription
gradeIntegerThe icon's grade.

Return

MaterialIcon — This object, for chaining.


setName(name)

Sets the name of the icon. Required.

The icon name defined in Google Font Icon, For example, check_box.

Any invalid names are abandoned and replaced with an empty string and results in the icon failing to render.

const materialIcon = CardService.newMaterialIcon().setName('search');

Parameters

NameTypeDescription
nameStringThe name of the icon.

Return

MaterialIcon — This object, for chaining.


setWeight(weight)

The stroke weight of the icon. Choose from {100, 200, 300, 400, 500, 600, 700}. If absent, default value is 400. If any other value is specified, the default value is used.

To preview different icon settings, go to Google Font Icons and adjust the settings under Customize.

const materialIcon =
    CardService.newMaterialIcon().setName('search').setWeight(700);

Parameters

NameTypeDescription
weightIntegerThe stroke weight of the icon.

Return

MaterialIcon — This object, for chaining.