Components
Avatar

Avatar

A graphical representation of the user, often used in profile sections.

PA

Getting Started

Start by importing the necessary components from the package:

import { Avatar, AvatarFallback, AvatarImage } from '@ark-ui/react'

Here is a basic example:

import { Avatar, AvatarFallback, AvatarImage } from '@ark-ui/react'

const Basic = () => (
  <Avatar.Root>
    <Avatar.Fallback>PA</Avatar.Fallback>
    <Avatar.Image src="https://i.pravatar.cc/300" alt="avatar" />
  </Avatar.Root>
)

Handling Events

Avatar also provides onError and onLoad events that can be utilized to handle situations when the image fails to load or has finished loading:

import { Avatar, AvatarFallback, AvatarImage } from '@ark-ui/react'

const Events = () => (
  <Avatar onError={() => console.log('error')} onLoad={() => console.log('loaded')}>
    <AvatarFallback>PA</AvatarFallback>
    <AvatarImage src="https://i.pravatar.cc/3000" alt="avatar" />
  </Avatar>
)

Conclusion

The Avatar component provides an efficient way to display user or entity representation within your applications. Its simple yet flexible structure allows it to easily fit within various use cases and design needs.

Previous

Accordion

Next

Carousel