Developers

Icon

An Icon Picker field returns an Icon object, including when no icon is selected. Use not icon.isEmpty() in Twig to check for a selection. The object identifies the selected icon and provides the output helpers used by Rendering Icons.

Properties

value

Type: string|null

The value of the icon. This will vary depending on the type of icon.

iconSet

Type: string|null

The folder, collection or variant within the source Icon Set.

iconSetHandle

Type: string|null

The current handle of the source Icon Set.

iconSetUid

Type: string|null

The stable identity of the source Icon Set. Saved selections keep this identity when a set is renamed. Deleting a set does not attach its selections to another set that reuses the handle.

label

Type: string|null

The named representation of the icon.

keywords

Type: string|null

The keywords used to search for the icon by. Defaults to the label.

type

Type: string|null

What type of icon this is: svg, sprite, glyph or css.

Stored Values

The value property identifies the icon within its set. Its format depends on the Icon Set type.

TypeDescriptionExample
svgThe filename and relative path of the icon./my-folder/twitter-square.svg
spriteThe name of the sprite within the spritesheet.twitter-square
glyphThe font glyph name and glyph decimal.twitter-square:61569
cssThe name of the icon for the remote icon source. Commonly a CSS class.twitter-square

Methods

count()

Returns: int

The character length of the value returned when the icon is converted to a string. In Twig, use the icon|length filter.

isEmpty()

Returns: bool

Returns true when no icon is selected and false when the object has an icon value.

getUrl()

Returns: string|null

Returns the image URL for a local SVG Folder or remote SVG set. Returns null for sprites and font or CSS icons. Use this URL as an image source, as shown in Rendering Icons.

getPath()

Returns: string

Return the full path to the icon. SVG Icons only.

getInline()

Returns: Twig\Markup|null

Returns SVG markup for a local SVG Folder or remote SVG set, or null when no SVG can be resolved. A remote SVG may require a server request. Use inline output only with trusted icon sources; Rendering Inline SVG shows where to place it.

getGlyph(format = 'charHex')

Returns: string|null

Returns an icon-font glyph in decimal, hex, char, or charHex format. The default is charHex. This applies only to Web Fonts.

getGlyphName()

Returns: string|null

Returns the named representation of a font glyph. Icon Font only.

Glyph Formats

FormatExample
getGlyph('decimal')Get the icon unicode (decimal).
getGlyph('hex')Get the icon unicode (hexadecimal).
getGlyph('char')Return a decimal HTML character reference such as .
getGlyph('charHex')Return a hexadecimal HTML character reference such as . This is the default.