All components

Avatar

Show a person when an image is unavailable.

Examples

Show a person when an image is unavailable

Maya Rivera

React code
import { Avatar, AvatarFallback } from "@accelerate/react/components";

export function Example() {
  return (
    <>
      <p><Avatar>
          <AvatarFallback>MR</AvatarFallback>
        </Avatar> Maya Rivera</p>
    </>
  );
}
Angular code
import { Component } from "@angular/core";
import { AccAvatar, AccAvatarFallback } from "@accelerate/angular/components";

@Component({
  selector: "app-example",
  imports: [
    AccAvatar,
    AccAvatarFallback,
  ],
  template: `
    <p><span accAvatar>
        <span accAvatarFallback>MR</span>
      </span> Maya Rivera</p>
  `,
})
export class Example {}

Installation

Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.

React
@accelerate/ui@0.4.0 and @accelerate/react@0.4.0
Angular
@accelerate/ui@0.4.0 and @accelerate/angular@0.2.0

Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.

Usage

Compose AvatarImage and AvatarFallback. Supply an accessible name through adjacent text or the avatar's label.

Import the React component Avatar from @accelerate/react/components. For Angular, add AccAvatar to the standalone component’s imports and use <span accAvatar>.

Examples use these React parts: Avatar, AvatarFallback. The Angular examples show the corresponding directives and template hosts.

API reference

AvatarImage
Supply src and an appropriate alt value when using a photo.
AvatarFallback
Shown until an image loads. Use nearby text to identify the person.