Class FontIcon

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.icon.AbstractIcon<FontIcon>
com.vaadin.flow.component.icon.FontIcon
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.ClickNotifier<FontIcon>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, HasTooltip, Serializable

public class FontIcon extends AbstractIcon<FontIcon>
Component for displaying an icon from a font icon collection. Note that the icon font must be loaded separately. One way to do this is by including it in the application's theme.
Author:
Vaadin Ltd
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    FontIcon(String... iconClassNames)
    Creates a font icon component with the given icon class names.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the hexadecimal code point that specifies a glyph from an icon font.
    Gets the color of this icon as a String.
    Gets the font family to use for the font icon.
    Gets the icon class names defining an icon font and/or a specific glyph inside an icon font.
    Gets the ligature name that specifies an icon from an icon font with support for ligatures.
    void
    setCharCode(String charCode)
    Sets the hexadecimal code point that specifies a glyph from an icon font.
    void
    Sets the color of the icon.
    void
    setFontFamily(String fontFamily)
    Sets the font family to use for the font icon.
    void
    setIconClassNames(String... iconClassNames)
    Sets the icon class names defining an icon font and/or a specific glyph inside an icon font.
    void
    setLigature(String ligature)
    Sets the ligature name that specifies an icon from an icon font with support for ligatures.

    Methods inherited from class com.vaadin.flow.component.icon.AbstractIcon

    setSize

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.ClickNotifier

    addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

    getTooltip, setTooltipText
  • Constructor Details

    • FontIcon

      public FontIcon()
      Default constructor. Creates an empty font icon.
    • FontIcon

      public FontIcon(String... iconClassNames)
      Creates a font icon component with the given icon class names. Example: new FontIcon("fa-solid", "fa-user").
      Parameters:
      iconClassNames - The icon class names, not null
      See Also:
  • Method Details

    • setIconClassNames

      public void setIconClassNames(String... iconClassNames)
      Sets the icon class names defining an icon font and/or a specific glyph inside an icon font. Example: setIconClassNames("fa-solid", "fa-user").
      Parameters:
      iconClassNames - The icon class names, not null
    • getIconClassNames

      public String[] getIconClassNames()
      Gets the icon class names defining an icon font and/or a specific glyph inside an icon font.
      Returns:
      The icon class names
    • setFontFamily

      public void setFontFamily(String fontFamily)
      Sets the font family to use for the font icon.
      Parameters:
      fontFamily - the font family to use
    • getFontFamily

      public String getFontFamily()
      Gets the font family to use for the font icon.
      Returns:
      the font family to use
    • setCharCode

      public void setCharCode(String charCode)
      Sets the hexadecimal code point that specifies a glyph from an icon font. Example: setCharCode("e001")
      Parameters:
      charCode - the character code to use
    • getCharCode

      public String getCharCode()
      Gets the hexadecimal code point that specifies a glyph from an icon font.
      Returns:
      the character code to use
    • setLigature

      public void setLigature(String ligature)
      Sets the ligature name that specifies an icon from an icon font with support for ligatures. Example: setLigature("home")
      Parameters:
      ligature - the ligature to use
    • getLigature

      public String getLigature()
      Gets the ligature name that specifies an icon from an icon font with support for ligatures.
      Returns:
      the ligature to use
    • setColor

      public void setColor(String color)
      Description copied from class: AbstractIcon
      Sets the color of the icon.

      The color should be in a format understood by the browser, e.g. "orange", "#FF9E2C" or "rgb(255, 158, 44)".

      Specified by:
      setColor in class AbstractIcon<FontIcon>
      Parameters:
      color - the color to set, may be null to clear the value
    • getColor

      public String getColor()
      Description copied from class: AbstractIcon
      Gets the color of this icon as a String.
      Specified by:
      getColor in class AbstractIcon<FontIcon>
      Returns:
      the color of the icon, or null if the color has not been set