# Avatar Avatar is a visual representation of a user, business, or entity. It provide quick visual identification in headers, comments, chat messages, and user profiles. **Category:** Components **Storybook:** https://doc.ux4g.gov.in/web/?path=/story/ux4g-components-avatar--introduction ## Variants documented in Storybook - BaseAvatar: https://doc.ux4g.gov.in/web/?path=/story/ux4g-components-avatar--baseavatar - StatusAvatar: https://doc.ux4g.gov.in/web/?path=/story/ux4g-components-avatar--statusavatar - AvatarGroup: https://doc.ux4g.gov.in/web/?path=/story/ux4g-components-avatar--avatargroup - ProfileAvatar: https://doc.ux4g.gov.in/web/?path=/story/ux4g-components-avatar--profileavatar ## Framework setup ### HTML / CDN ```html ``` ### React ```bash npm install ux4g-web-components ``` ```jsx import 'ux4g-web-components/styles.css'; import 'ux4g-web-components/design-system'; ``` ### Angular Update `angular.json`: ```json { "styles": [ "node_modules/ux4g-web-components/styles/ux4g.css", "src/styles.css" ], "scripts": [ "node_modules/ux4g-web-components/dist/runtime/design-system.js" ] } ``` ## Code examples The snippets below are extracted from the Storybook canvas for Avatar. Each example shows the rendered HTML, the equivalent React JSX, and the Angular template markup. ### 1. Avatar Group — Group Variants HTML: ```html
avatar
avatar
avatar
``` React: ```jsx import React from 'react'; const AvatarExample1Demo = () => ( <> {/* Variant: Avatar Group - Three Members */}
avatar
avatar
avatar
); export default AvatarExample1Demo; ``` Angular: ```html
avatar
avatar
avatar
``` ### 2. Avatar Group — Group Sizes HTML: ```html
avatar
avatar
avatar
avatar
avatar
avatar
``` React: ```jsx import React from 'react'; const AvatarExample2Demo = () => ( <> {/* Variant: Avatar Group - XS */}
avatar
avatar
{/* Variant: Avatar Group - S */}
avatar
avatar
{/* Variant: Avatar Group - M */}
avatar
avatar
); export default AvatarExample2Demo; ``` Angular: ```html
avatar
avatar
avatar
avatar
avatar
avatar
``` ### 3. Avatar Group — Collapsed Groups HTML: ```html
Max 2
+6
Max 3
+3
Max 4
+2
Max 5
+1
``` React: ```jsx import React from 'react'; const AvatarExample3Demo = () => ( <>
{/* Max 2 */}
Max 2
+6
{/* Max 3 */}
Max 3
+3
{/* Max 4 */}
Max 4
+2
{/* Max 5 */}
Max 5
+1
); export default AvatarExample3Demo; ``` Angular: ```html
Max 2
+6
Max 3
+3
Max 4
+2
Max 5
+1
``` ### 4. Base Avatar — Initials Scaling HTML: ```html
XS
S
M
L
XL
2XL
3XL
``` React: ```jsx import React from 'react'; const AvatarExample4Demo = () => ( <> {/* Variant: Initial Avatar - XS */}
XS
{/* Variant: Initial Avatar - S */}
S
{/* Variant: Initial Avatar - M */}
M
{/* Variant: Initial Avatar - L */}
L
{/* Variant: Initial Avatar - XL */}
XL
{/* Variant: Initial Avatar - 2XL */}
2XL
{/* Variant: Initial Avatar - 3XL */}
3XL
); export default AvatarExample4Demo; ``` Angular: ```html
XS
S
M
L
XL
2XL
3XL
``` ### 5. Base Avatar — Icon Scaling HTML: ```html
person
person
person
person
person
person
person
``` React: ```jsx import React from 'react'; const AvatarExample5Demo = () => ( <> {/* Variant: Icon Avatar - XS */}
person
{/* Variant: Icon Avatar - S */}
person
{/* Variant: Icon Avatar - M */}
person
{/* Variant: Icon Avatar - L */}
person
{/* Variant: Icon Avatar - XL */}
person
{/* Variant: Icon Avatar - 2XL */}
person
{/* Variant: Icon Avatar - 3XL */}
person
); export default AvatarExample5Demo; ``` Angular: ```html
person
person
person
person
person
person
person
``` ### 6. Base Avatar — Image Scaling HTML: ```html
avatar
avatar
avatar
avatar
avatar
avatar
avatar
``` React: ```jsx import React from 'react'; const AvatarExample6Demo = () => ( <> {/* Variant: Image Avatar - XS */}
avatar
{/* Variant: Image Avatar - S */}
avatar
{/* Variant: Image Avatar - M */}
avatar
{/* Variant: Image Avatar - L */}
avatar
{/* Variant: Image Avatar - XL */}
avatar
{/* Variant: Image Avatar - 2XL */}
avatar
{/* Variant: Image Avatar - 3XL */}
avatar
); export default AvatarExample6Demo; ``` Angular: ```html
avatar
avatar
avatar
avatar
avatar
avatar
avatar
``` ### 7. Introduction — Introduction HTML: ```html
Components

Avatar

Avatar is a visual representation of a user, business, or entity. It provide quick visual identification in headers, comments, chat messages, and user profiles.

Implementation Showcase

Visual demonstration of the four primary avatar configurations supported by the design system.

Base Avatars

JD
person

Status Avatars

priority_high

Avatar Groups

+5

Profile Avatars

edit

CSS Class Reference

Avatar Sizes

3-Extra Large ux4g-avatar-3xl
2-Extra Large ux4g-avatar-2xl
Extra Large ux4g-avatar-xl
Large ux4g-avatar-l
Medium [Default] ux4g-avatar-m
Small ux4g-avatar-s
Extra Small ux4g-avatar-xs

Status Badge Sizes

Large ux4g-badge-l
Medium [Default] ux4g-badge-m
Small ux4g-badge-s

Profile Badge Sizes

3-Extra Large ux4g-badge-profile-3xl
2-Extra Large ux4g-badge-profile-2xl
Extra Large ux4g-badge-profile-xl
Large [Default] ux4g-badge-profile-l

Status & Badge Variants

Online Status ux4g-badge-dot-success
Offline Status ux4g-badge-dot-neutral
Busy / Busy Icon ux4g-badge-icon-warning
Success Icon ux4g-badge-icon-success
Error Icon ux4g-badge-icon-danger
Profile Verify Icon ux4g-badge-icon-primary
``` React: ```jsx import React from 'react'; const AvatarExample7Demo = () => ( <>
Components

Avatar

Avatar is a visual representation of a user, business, or entity. It provide quick visual identification in headers, comments, chat messages, and user profiles.

Implementation Showcase

Visual demonstration of the four primary avatar configurations supported by the design system.

{/* Block 1: Base Avatars */}

Base Avatars

JD
person
{/* Block 2: Status Avatars */}

Status Avatars

priority_high
{/* Block 3: Avatar Groups */}

Avatar Groups

+5
{/* Block 4: Profile Avatars */}

Profile Avatars

edit

CSS Class Reference

{/* Avatar Sizes */}

Avatar Sizes

3-Extra Large ux4g-avatar-3xl
2-Extra Large ux4g-avatar-2xl
Extra Large ux4g-avatar-xl
Large ux4g-avatar-l
Medium [Default] ux4g-avatar-m
Small ux4g-avatar-s
Extra Small ux4g-avatar-xs
{/* Status Badge Sizes */}

Status Badge Sizes

Large ux4g-badge-l
Medium [Default] ux4g-badge-m
Small ux4g-badge-s
{/* Profile Badge Sizes */}

Profile Badge Sizes

3-Extra Large ux4g-badge-profile-3xl
2-Extra Large ux4g-badge-profile-2xl
Extra Large ux4g-badge-profile-xl
Large [Default] ux4g-badge-profile-l
{/* Status & Badge Variants */}

Status & Badge Variants

Online Status ux4g-badge-dot-success
Offline Status ux4g-badge-dot-neutral
Busy / Busy Icon ux4g-badge-icon-warning
Success Icon ux4g-badge-icon-success
Error Icon ux4g-badge-icon-danger
Profile Verify Icon ux4g-badge-icon-primary
); export default AvatarExample7Demo; ``` Angular: ```html
Components

Avatar

Avatar is a visual representation of a user, business, or entity. It provide quick visual identification in headers, comments, chat messages, and user profiles.

Implementation Showcase

Visual demonstration of the four primary avatar configurations supported by the design system.

Base Avatars

JD
person

Status Avatars

priority_high

Avatar Groups

+5

Profile Avatars

edit

CSS Class Reference

Avatar Sizes

3-Extra Large ux4g-avatar-3xl
2-Extra Large ux4g-avatar-2xl
Extra Large ux4g-avatar-xl
Large ux4g-avatar-l
Medium [Default] ux4g-avatar-m
Small ux4g-avatar-s
Extra Small ux4g-avatar-xs

Status Badge Sizes

Large ux4g-badge-l
Medium [Default] ux4g-badge-m
Small ux4g-badge-s

Profile Badge Sizes

3-Extra Large ux4g-badge-profile-3xl
2-Extra Large ux4g-badge-profile-2xl
Extra Large ux4g-badge-profile-xl
Large [Default] ux4g-badge-profile-l

Status & Badge Variants

Online Status ux4g-badge-dot-success
Offline Status ux4g-badge-dot-neutral
Busy / Busy Icon ux4g-badge-icon-warning
Success Icon ux4g-badge-icon-success
Error Icon ux4g-badge-icon-danger
Profile Verify Icon ux4g-badge-icon-primary
``` ### 8. Profile Avatar — Profile Badges HTML: ```html
avatar
avatar
avatar shield
avatar edit
avatar local_see
avatar remove
``` React: ```jsx import React from 'react'; const AvatarExample8Demo = () => ( <> {/* Verify */}
avatar
{/* Star */}
avatar
{/* Admin (Shield) */}
avatar shield
{/* Edit */}
avatar edit
{/* Gallery */}
avatar local_see
{/* Remove */}
avatar remove
); export default AvatarExample8Demo; ``` Angular: ```html
avatar
avatar
avatar shield
avatar edit
avatar local_see
avatar remove
``` ### 9. Profile Avatar — Profile Sizes HTML: ```html
avatar edit
avatar edit
avatar edit
avatar edit
``` React: ```jsx import React from 'react'; const AvatarExample9Demo = () => ( <> {/* Large */}
avatar edit
{/* Extra Large */}
avatar edit
{/* 2-Extra Large */}
avatar edit
{/* 3-Extra Large */}
avatar edit
); export default AvatarExample9Demo; ``` Angular: ```html
avatar edit
avatar edit
avatar edit
avatar edit
``` ### 10. Status Avatar — Status Badges HTML: ```html
avatar
avatar
avatar do_disturb_on
avatar check
avatar close
avatar priority_high
``` React: ```jsx import React from 'react'; const AvatarExample10Demo = () => ( <>
{/* Online */}
avatar
{/* Offline */}
avatar
{/* Busy */}
avatar do_disturb_on
{/* Success */}
avatar check
{/* Error */}
avatar close
{/* Warning */}
avatar priority_high
); export default AvatarExample10Demo; ``` Angular: ```html
avatar
avatar
avatar do_disturb_on
avatar check
avatar close
avatar priority_high
``` ### 11. Status Avatar — Status Sizes HTML: ```html
avatar check
avatar check
avatar check
``` React: ```jsx import React from 'react'; const AvatarExample11Demo = () => ( <> {/* Variant: Status Avatar - Small Badge Size */}
avatar check
{/* Variant: Status Avatar - Medium Badge Size */}
avatar check
{/* Variant: Status Avatar - Large Badge Size */}
avatar check
); export default AvatarExample11Demo; ``` Angular: ```html
avatar check
avatar check
avatar check
``` ## Accessibility notes - Use semantic HTML and required ARIA attributes where the Storybook example shows them. - Ensure visible focus indicators and keyboard operability. - Test color contrast against WCAG 2.1 AA.