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
Type: string|null
The value of the icon. This will vary depending on the type of icon.
Type: string|null
The folder, collection or variant within the source Icon Set.
Type: string|null
The current handle of the source Icon Set.
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.
Type: string|null
The named representation of the icon.
Type: string|null
The keywords used to search for the icon by. Defaults to the label.
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.
| Type | Description | Example |
|---|---|---|
svg | The filename and relative path of the icon. | /my-folder/twitter-square.svg |
sprite | The name of the sprite within the spritesheet. | twitter-square |
glyph | The font glyph name and glyph decimal. | twitter-square:61569 |
css | The name of the icon for the remote icon source. Commonly a CSS class. | twitter-square |
Methods
Returns: int
The character length of the value returned when the icon is converted to a string. In Twig, use the icon|length filter.
Returns: bool
Returns true when no icon is selected and false when the object has an icon value.
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.
Returns: string
Return the full path to the icon. SVG Icons only.
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.
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.
Returns: string|null
Returns the named representation of a font glyph. Icon Font only.
Glyph Formats
| Format | Example |
|---|---|
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. |