Package com.vaadin.flow.component.icon
Class Icon
java.lang.Object
com.vaadin.flow.component.Component
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<Icon>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.shared.HasTooltip,Serializable
@NpmPackage(value="@vaadin/icons",
version="25.0.0-alpha20")
@JsModule("@vaadin/icons/vaadin-iconset.js")
public class Icon
extends AbstractIcon<Icon>
Component for displaying an icon from the
Vaadin Icons collection.
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIcon()Creates an empty Icon.Icon(VaadinIcon icon) Creates an Icon component that displays the given icon fromVaadinIcon.Creates an Icon component that displays the given icon from vaadin-icons collection.Creates an Icon component that displays the giveniconfrom the givencollection. -
Method Summary
Modifier and TypeMethodDescriptionGets the collection of the icon (the part before :).getColor()Gets the color of this icon as a String.getIcon()Gets the full icon name, including the collection.voidSets the color of the icon.voidsetIcon(VaadinIcon icon) Sets the icon to the given Vaadin icon.voidSets the icon to the given icon.voidSets the icon to the giveniconfrom the givencollection.Methods inherited from class com.vaadin.flow.component.icon.AbstractIcon
setSizeMethods 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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipText
-
Constructor Details
-
Icon
public Icon()Creates an empty Icon. -
Icon
Creates an Icon component that displays the given icon fromVaadinIcon.- Parameters:
icon- the icon to display
-
Icon
Creates an Icon component that displays the given icon from vaadin-icons collection.- Parameters:
icon- the icon name
-
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 Details
-
setIcon
Sets the icon to the given icon.If the icon name contains a ":", the first part is used as the collection and the second part as the icon name. If the icon name does not contain a ":", the current collection is used (vaadin by default).
- Parameters:
icon- the icon name
-
setIcon
Sets the icon to the given Vaadin icon.- Parameters:
icon- the icon name
-
getIcon
Gets the full icon name, including the collection.- Returns:
- the icon name or
nullif no icon is set
-
setIcon
Sets the icon to 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
-
getCollection
Gets the collection of the icon (the part before :).- Returns:
- the collection of the icon or
nullif no collection is set
-
setColor
Description copied from class:AbstractIconSets 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:
setColorin classAbstractIcon<Icon>- Parameters:
color- the color to set, may benullto clear the value
-
getColor
Description copied from class:AbstractIconGets the color of this icon as a String.- Specified by:
getColorin classAbstractIcon<Icon>- Returns:
- the color of the icon, or
nullif the color has not been set
-