Package com.vaadin.flow.component.icon
Class Icon
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.icon.Icon
-
- All Implemented Interfaces:
AttachNotifier,ClickNotifier<Icon>,DetachNotifier,HasElement,HasStyle,HasTooltip,Serializable
@Tag("vaadin-icon") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="23.5.4") @NpmPackage(value="@vaadin/icons",version="23.5.4") @NpmPackage(value="@vaadin/icon",version="23.5.4") @NpmPackage(value="@vaadin/vaadin-icon",version="23.5.4") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/icons/vaadin-iconset.js") @JsModule("@vaadin/icon/src/vaadin-icon.js") public class Icon extends Component implements HasStyle, ClickNotifier<Icon>, HasTooltip
Component for displaying an icon from the Vaadin Icons collection.- Author:
- Vaadin Ltd
- See Also:
VaadinIcon, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Icon()Creates an Icon component that displays a Vaadin logo.Icon(VaadinIcon icon)Creates an Icon component that displays the given icon fromVaadinIcon.Icon(String icon)Creates an Icon component that displays the given icon from vaadin-icons collection.Icon(String collection, String icon)Creates an Icon component that displays the giveniconfrom the givencollection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetColor()Gets the fill color of this icon as a String.voidsetColor(String color)Sets the fill color of the icon.voidsetSize(String size)Sets the width and the height of the icon.-
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, 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 Detail
-
Icon
public Icon()
Creates an Icon component that displays a Vaadin logo.
-
Icon
public Icon(VaadinIcon icon)
Creates an Icon component that displays the given icon fromVaadinIcon.- Parameters:
icon- the icon to display
-
Icon
public Icon(String icon)
Creates an Icon component that displays the given icon from vaadin-icons collection.- Parameters:
icon- the icon name
-
Icon
public Icon(String collection, String icon)
Creates an Icon component that displays the giveniconfrom the givencollection. If you want to use a custom<vaadin-iconset>-based icon set, you also need to add a dependency and an import for it, example:@NpmPackage(value = "custom-icons", version = "1.0.0") @JsModule("custom-icons/iconset.js") public class MyView extends Div {- Parameters:
collection- the icon collectionicon- the icon name
-
-
Method Detail
-
setSize
public void setSize(String size)
Sets the width and the height of the icon.The size should be in a format understood by the browser, e.g. "100px" or "2.5em".
- Parameters:
size- the size to set, may benullto clear the value
-
setColor
public void setColor(String color)
Sets the fill color of the icon.The color should be in a format understood by the browser, e.g. "orange", "#FF9E2C" or "rgb(255, 158, 44)".
- Parameters:
color- the fill color to set, may benullto clear the value
-
getColor
public String getColor()
Gets the fill color of this icon as a String.- Returns:
- the fill color of the icon, or
nullif the color has not been set
-
-