Skip to content

Avatar

Avatars display user profile image, initials or fallback icon.

Importing

To use the avatar component, first you need to register the component inside the page. You can register the component manually by importing the register function:

ts
import { register } from "@tapsioss/web-components/avatar";

register(); // Now the avatar component is ready to use!
ts
import { registerAvatar } from "@tapsioss/web-components";

registerAvatar(); // Now the avatar component is ready to use!

Also you can automatically register the component by importing it with the following approach:

ts
import "@tapsioss/web-components/avatar/element";

TIP

If you want to use all the component in your app, you can call registerAll at the root of your project.

ts
import { registerAll } from "@tapsioss/web-components";

registerAll(); // All the components are now available

In the React package, you can easily add the component using the following code:

ts
import { Avatar } from "@tapsioss/react-components";

Component Usage

html
<tapsi-avatar></tapsi-avatar>
tsx
<Avatar />

Properties

NameAttribute NameDescriptionTypeDefault Value
imageimageThe image source to use for the avatar.string""
labellabelA label to use to describe the avatar to assistive devices.string""
altaltThe alternative text description of the avatar image, used for accessibility.string""
loadingloadingIndicates how the browser should load the image."eager" | "lazy""eager"
sizesizeThe size of the avatar.| "xs"
| "sm"
| "md"
| "lg"
| "xlg"
| "xxlg"
"md"

Slots

NameValueDescription
DEFAULT-The default slot to use when image is not present.

TIP

The value of slots are available for developer as JavaScript Variables:

ts
// Option 1
import { AvatarSlots } from "@tapsioss/web-components";

// Option 2
import { Slots } from "@tapsioss/web-components/avatar";
ts
// Option 1
import { AvatarSlots } from "@tapsioss/react-components";

// Option 2
import { Slots } from "@tapsioss/react-components/Avatar";

Created with 🧡