Skip to content
Gravity Logo / Docs Gravity home
Browse documentation
Documentation/Gravity Web

Avatar

The Avatar component is an image element with a fallback text for representing the user.

Usage

import { Avatar } from 'components/lib';

function MyComponent({ ...props }){
  return (
    <Avatar src='path/to/image.jpg' fallback='KG' />
  );
}

Props

PropDescriptionRequiredValue
classNamecustom stylesoptionalSCSS or Tailwind object
fallbackFallback text when image is not availableoptionalstring
srcImage source URLoptionalstring

Notes

  • The Avatar component uses AvatarPrimitive.Root, AvatarPrimitive.Image, and AvatarPrimitive.Fallback from @radix-ui/react-avatar.
  • Custom styles can be applied using the className prop.
  • The src prop specifies the source URL for the avatar image.
  • The fallback prop provides fallback content when the image is missing.
  • For more details, refer to the Shadcn Avatar documentation.