Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Attributes
-
initials :string
-
Specifies the initials of the avatar. Will only be displayed if the src attribute is null. Required if src attribute is provided for accessibility purposes. Will be displayed if the src attribute is not specified, or in high contrast mode for accessibility purposes.
- Default Value:
null
Names
Item Name Property initialsProperty change event initialsChangedProperty change listener attribute (must be of type function) on-initials-changedExamples
Renders a default medium avatar with initials
<oj-avatar initials='AB'></oj-avatar>Get or set the
initialsproperty after initialization//Get avatar initials var initials = myAvatar.initials; //Set initials property to 'NT' myAvatar.initials = "NT"; -
size :string
-
Specifies the size of the avatar.
- Default Value:
"md"
Supported Values:
Name Type Description "xxs"string extra, extra small avatar "xs"string extra small avatar "sm"string small avatar "md"string medium avatar, default value "lg"string large avatar "xl"string extra large avatar "xxl"string extra, extra large avatar Names
Item Name Property sizeProperty change event sizeChangedProperty change listener attribute (must be of type function) on-size-changedExamples
Renders avatar displaying default placeholder image with
sizeattribute set to large<oj-avatar size='lg'></oj-avatar>Get or set the
sizeproperty after initialization//Get avatar size var size = myAvatar.size; //Set size property to xs myAvatar.size = "xs"; -
src :string
-
Specifies the src for the image of the avatar. Image will be rendered as a background image. In high contrast mode, initials will be displayed instead since background images will not be rendered.
- Default Value:
null
Names
Item Name Property srcProperty change event srcChangedProperty change listener attribute (must be of type function) on-src-changedExamples
Renders a default medium avatar with a image
<oj-avatar src='image.jpg'></oj-avatar>Get or set the
srcproperty after initialization//Get avatar src var src = myAvatar.src; //Set src property to 'image2.jpg' myAvatar.src = "image2.jpg";
Methods
-
getProperty(property) → {any}
-
Retrieves a value for a property or a single subproperty for complex properties.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
Example
Get a single subproperty of a complex property:
var subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2'); -
setProperties(properties) → {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description propertiesObject An object containing the property and value pairs to set. Returns:
- Type
- void
Example
Set a batch of properties:
myComponent.setProperties({"prop1": "value1", "prop2.subprop": "value2", "prop3": "value3"}); -
setProperty(property, value) → {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
Parameters:
Name Type Description propertystring The property name to set. Supports dot notation for subproperty access. valueany The new value to set the property to. Returns:
- Type
- void
Example
Set a single subproperty of a complex property:
myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");