@Tag(value="vaadin-avatar") @JsModule(value="@vaadin/vaadin-avatar/src/vaadin-avatar.js") @NpmPackage(value="@vaadin/vaadin-avatar", version="1.0.4") public class Avatar extends Component implements HasStyle, HasSize, HasTheme
vaadin-avatar
element.Modifier and Type | Class and Description |
---|---|
static class |
Avatar.AvatarI18n
The internationalization properties for
AvatarGroup . |
Constructor and Description |
---|
Avatar()
Creates a new empty avatar.
|
Avatar(String name)
Creates a new avatar with the provided name.
|
Avatar(String name,
String url)
Creates a new avatar with the provided name and url.
|
Modifier and Type | Method and Description |
---|---|
void |
addThemeVariants(AvatarVariant... variants)
Adds theme variants to the avatar component.
|
String |
getAbbreviation()
Gets the abbreviation that was set for the avatar.
|
Integer |
getColorIndex()
Gets the color index for the avatar.
|
Avatar.AvatarI18n |
getI18n()
Gets the internationalization object previously set for this component.
|
String |
getImage()
Gets the image url that was set for the avatar.
|
AbstractStreamResource |
getImageResource()
Gets the image that was set for the avatar.
|
String |
getName()
Gets the name that was set for the avatar.
|
void |
removeThemeVariants(AvatarVariant... variants)
Removes theme variants from the avatar component.
|
void |
setAbbreviation(String abbr)
Sets the abbreviation for the avatar.
|
void |
setColorIndex(Integer colorIndex)
Sets the color index for the avatar.
|
void |
setI18n(Avatar.AvatarI18n i18n)
Sets the internationalization properties for this component.
|
void |
setImage(String url)
Sets the image url for the avatar.
|
void |
setImageResource(AbstractStreamResource resource)
Sets the image for the avatar.
|
void |
setName(String name)
Sets the name for the avatar.
|
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
getElement
addAttachListener
addDetachListener
public Avatar()
The avatar displays the user icon in the avatar and "Anonymous" in the tooltip unless overridden by setting other properties.
public Avatar(String name)
name
- the name for the avatarsetName(String)
public Avatar(String name, String url)
name
- the name for the avatarurl
- the image urlsetName(String)
,
setImage(String)
public Avatar.AvatarI18n getI18n()
Note: updating the object content that is gotten from this method will
not update the lang on the component if not set back using
setI18n(AvatarI18n)
null
, If the i18n
properties weren't set.public void setI18n(Avatar.AvatarI18n i18n)
i18n
- the internationalized properties, not null
public String getName()
public void setName(String name)
The name is displayed in a tooltip on hover.
Automatically deduced abbreviation is displayed in the avatar if no abbreviation or image is set.
name
- the name for the avatarpublic String getAbbreviation()
public void setAbbreviation(String abbr)
The abbreviation will be displayed in the avatar if no image has been set.
abbr
- the abbreviationpublic String getImage()
public AbstractStreamResource getImageResource()
null
if the resource has not
been setpublic void setImage(String url)
The image will be displayed in the avatar even if abbreviation or name is set.
Setting the image with this method resets the image resource provided
with setImageResource(AbstractStreamResource)
url
- the image urlsetImageResource(AbstractStreamResource)
public void setImageResource(AbstractStreamResource resource)
Setting the image as a resource with this method resets the image URL
that was set with setImage(String)
resource
- the resource value or null
to remove the resourcesetImage(String)
public Integer getColorIndex()
null
if the index has not been setpublic void setColorIndex(Integer colorIndex)
The color index defines which color will be used for the border of the
avatar. Color index N applies CSS variable --vaadin-user-color-N
to the border.
colorIndex
- the color index or null
to remove the indexpublic void addThemeVariants(AvatarVariant... variants)
variants
- theme variants to addpublic void removeThemeVariants(AvatarVariant... variants)
variants
- theme variants to removeCopyright © 2025. All rights reserved.