Avatar
A graphical representation of the user, often used in profile sections.
A graphical representation of the user, often used in profile sections.
To set up the avatar correctly, you’ll need to understand its anatomy and how we name its parts.
Each part includes a
data-partattribute to help identify them in the DOM.
Learn how to use the Avatar component in your project. Let’s take a look at
the most basic example:
import { Avatar } 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>
)
import { Avatar } from '@ark-ui/solid'
const Basic = () => (
  <Avatar.Root>
    <Avatar.Fallback>PA</Avatar.Fallback>
    <Avatar.Image src="https://i.pravatar.cc/300" alt="avatar" />
  </Avatar.Root>
)
<script setup lang="ts">
import { Avatar } from '@ark-ui/vue'
</script>
<template>
  <Avatar.Root>
    <Avatar.Fallback>PA</Avatar.Fallback>
    <Avatar.Image src="https://i.pravatar.cc/3000" alt="avatar" />
  </Avatar.Root>
</template>
Avatar allows you to listen for loading state changes.
import { Avatar } from '@ark-ui/react'
const Events = () => (
  <Avatar.Root onLoadingStatusChange={(details) => console.log(details.status)}>
    <Avatar.Fallback>PA</Avatar.Fallback>
    <Avatar.Image src="https://i.pravatar.cc/3000" alt="avatar" />
  </Avatar.Root>
)
import { Avatar } from '@ark-ui/solid'
const Events = () => (
  <Avatar.Root onLoadingStatusChange={(details) => console.log(details.status)}>
    <Avatar.Fallback>PA</Avatar.Fallback>
    <Avatar.Image src="https://i.pravatar.cc/3000" alt="avatar" />
  </Avatar.Root>
)
<script setup lang="ts">
import { Avatar } from '@ark-ui/vue'
</script>
<template>
  <Avatar @loading-status-change="(status) => console.log(status)">
    <Avatar.Fallback>PA</Avatar.Fallback>
    <Avatar.Image src="https://i.pravatar.cc/3000" alt="avatar" />
  </Avatar>
</template>
| Prop | Type | Default | 
|---|---|---|
| asChildRender as a different element type. | boolean | |
| dirThe document's text/writing direction. | 'ltr' | 'rtl' | "ltr" | 
| getRootNodeA root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. | () => Node | ShadowRoot | Document | |
| idThe unique identifier of the machine. | string | |
| onLoadingStatusChangeFunctional called when the image loading status changes. | (details: StatusChangeDetails) => void | 
| Prop | Type | Default | 
|---|---|---|
| asChildRender as a different element type. | boolean | 
| Prop | Type | Default | 
|---|---|---|
| asChildRender as a different element type. | boolean |