Skip to content
Page

Avatar

Picture, initials, or icon that stands for a person.

JA
PG
import {
Avatar,
AvatarImage,
AvatarFallback,
AvatarText,
AvatarIcon,
AvatarBadge,
} from "@pelagornis/page/components";

The preview above renders this file. Copy it into src/components/ to start from it.

src/components/AvatarExample.tsx
import { Avatar, AvatarIcon, AvatarText, Stack } from "@pelagornis/page/components";
export default function AvatarDemo() {
return (
<Stack direction="row" gap="sizeMedium" align="center" wrap>
<Avatar layout="initials" size="sm">
<AvatarText>JA</AvatarText>
</Avatar>
<Avatar layout="initials" size="md" showStatus status="online">
<AvatarText>PG</AvatarText>
</Avatar>
<Avatar layout="icon" size="lg">
<AvatarIcon name="person" />
</Avatar>
</Stack>
);
}

Avatar is composed from parts that share React state. Children written in MDX are rendered as separate islands, so the parts can’t reach each other. Put the composition in a .tsx file, like the example above, and import that file instead.

src/content/docs/example.mdx
---
title: Example
---
import AvatarExample from "../../components/AvatarExample";
<AvatarExample client:load />

client:load hydrates the island on page load. Use client:visible for content far down the page.

Markdoc tags render Astro components, and this one needs client state. Wrap the example in an .astro file that hydrates it, then register that file as a tag.

src/components/markdoc/AvatarExample.astro
---
import AvatarExample from "../AvatarExample";
---
<AvatarExample client:load />
markdoc.config.mjs
import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";
import starlightMarkdoc from "@astrojs/starlight-markdoc";
import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({
extends: [starlightMarkdoc(), pageMarkdoc()],
tags: {
"avatar-example": {
render: component("./src/components/markdoc/AvatarExample.astro"),
selfClosing: true,
},
},
});
src/content/docs/example.mdoc
{% avatar-example /%}

Values the component accepts for each variant prop.

PropValues
sizexs sm md lg xl
layoutimage icon initials

Parts of the component and the data-refineui role each one renders.

PartRole
rootavatar