Element: <oj-c-avatar>

CORE PACK

Oracle® JavaScript Extension Toolkit (JET)
17.1.0

G12196-01

Since:
  • 13.0.0
Module:
  • avatar

Note: This component supersedes the following component: <oj-avatar>. Migration info available at preceding link.

QuickNav

Attributes

Other Topics


JET Avatar

Description: Themeable, WAI-ARIA-compliant element that often represents a person.

An oj-c-avatar is an icon capable of displaying a custom image, or initials, or a placeholder image. The order of precedence for what is displayed, in order from highest to lowest, is:

  1. Icon specified through the "icon-class" attribute
  2. Custom image specified through the "src" attribute
  3. Initials specified through the "initials" attribute
  4. Default placeholder image
//Avatar with initials
<oj-c-avatar initials="AB">
</oj-c-avatar>

Accessibility

If any associated information (e.g. the name of the person represented by the oj-c-avatar) is already available to assistive technologies, for example by rendering the name in addition to the avatar as part of the page content, then setting the aria-label is optional. Otherwise setting the aria-label is required by passing a descriptive text to the aria-label attribute. The component will then internally set role='img' if the aria-label is set.

JET Avatar does not have any interaction with the application, therefore it is not keyboard navigable by default. The aria-label will be picked up by the tabbable/focusable parent unless it is overriden by the application. The parent of the avatar is responsible for providing aria-* props and tooltip support if the avatar is informational or in an actionable element

In order to meet accessibility requirements for text, color contrast ratio between the background color and text must be greater than 4.5 for the two smallest avatars and 3.1 for the five larger avatars. Avatar's default background satisfies the 4.5 color contrast ratio. If colors are customized through theming, the application is responsible for specifying colors that satisfy the contrast ratio requirements.

Image

The avatar will display an icon if the iconClass is populated. If it is not, then the avatar will display the image provided from the src attribute if the src attribute is populated. If the src attribute is not provided and the initials have been, the initials will be displayed. If neither iconClass, src nor initials attributes are populated, a single person placeholder image is shown. Examples displaying each type of avatar:

//Individual Placeholder
<oj-c-avatar>
 </oj-c-avatar>
//Icon
<oj-c-avatar icon-class="oj-ux-ico-contact-group">
 </oj-c-avatar>
//Initials
<oj-c-avatar initials="AB">
</oj-c-avatar>
//Image
<oj-c-avatar initials="AB" src="image.jpg">
</oj-c-avatar>


Usage

Signature:

interface CAvatarElement

Typescript Import Format
//To typecheck the element APIs, import as below.
import { CAvatarElement } from "oj-c/avatar";

//For the transpiled javascript to load the element's module, import as below
import "oj-c/avatar";

For additional information visit:

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

background :"neutral"|"orange"|"green"|"teal"|"blue"|"slate"|"pink"|"purple"|"lilac"|"gray"

Specifies the background of the avatar.
Supported Values:
Value Description
blue Blue background
gray Gray background
green Green background
lilac Lilac background
neutral Neutral background (default, if unspecified)
orange Orange background
pink Pink background
purple Purple background
slate Slate background
teal Teal background
Default Value:
  • "neutral"
Names
Item Name
Property background
Property change event backgroundChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-background-changed

icon-class :string

Specifies the icon class to be displayed. IconClass will have precedence over src and initials.
Names
Item Name
Property iconClass
Property change event iconClassChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-icon-class-changed

initials :(string|null)

Specifies the initials of the avatar. Initials will not be displayed if src or iconClass attributes are specified. IntlConverterUtils.getInitials can be used to generate initials from first and last names in a locale-specific manner.
Names
Item Name
Property initials
Property change event initialsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-initials-changed

shape :"square"|"circle"

Specifies the shape of the avatar. Can be square or circle.The default value of this property varies by theme.
Supported Values:
Value Description
circle circular avatar
square square avatar (default, if unspecified)
Default Value:
  • "square"
Names
Item Name
Property shape
Property change event shapeChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-shape-changed

size :"2xs"|"xs"|"sm"|"md"|"lg"|"xl"|"2xl"

Specifies the size of the avatar.
Supported Values:
Value Description
2xl extra, extra large avatar
2xs extra, extra small avatar
lg large avatar
md medium avatar (default, if unspecified)
sm small avatar
xl extra large avatar
xs extra small avatar
Default Value:
  • "md"
Names
Item Name
Property size
Property change event sizeChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-size-changed

src :(string|null)

Specifies the src for the image of the avatar. Image will be rendered as a background image. Src will have precedence over initials, but not icon.
Names
Item Name
Property src
Property change event srcChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-src-changed

Methods

getProperty(property) : {any}

Retrieves the value of a property or a subproperty.
Parameters:
Name Type Description
property The property name to get. Supports dot notation for subproperty access.
Returns:
Type
any

setProperties(properties) : {void}

Performs a batch set of properties.
Parameters:
Name Type Description
properties An object containing the property and value pairs to set.
Returns:
Type
void

setProperty(property, value) : {void}

Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a corresponding event.
Parameters:
Name Type Description
property The property name to set. Supports dot notation for subproperty access.
value The new value to set the property to.
Returns:
Type
void