# Persona Avatar

> An agent's face: a shape and a color with eyes that move with what it's doing.

Page: https://uicontext.com/docs/components/persona-avatar

Group: Agents.

## When to use

An agent's face: a shape and a color with eyes that move with what it's doing. Use [Avatar](https://uicontext.com/docs/components/avatar.md) instead when the face is a person's.

## Usage

```ts
import { PersonaAvatar } from "./ui/uicontext/components/Persona.ts"

export const InboxFace = <M>(h: Html.H<M>, working: boolean) =>
	PersonaAvatar(h, { persona: { shape: "drop", color: "blue" }, size: "md", state: working ? "working" : "idle" })
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### Shapes and colors

Eight shapes in ten colors. A dozen agents stay apart by face alone, and every face reads at 16px.

```ts title="src/demo.ts" source="www/src/examples/persona-avatar/demo.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { PersonaAvatar, personaColors, personaShapes } from "./ui/uicontext/components/Persona.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({
	grid: { display: "grid", gridTemplateColumns: "repeat(8, 32px)", gap: space.md, justifyContent: "center" },
})

export const ShapesAndColors = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.grid)).children(
		personaColors.flatMap((color) => personaShapes.map((shape) => PersonaAvatar(h, { persona: { shape, color }, size: "md" }).key(`${color}-${shape}`))),
	)
```

### What it's doing

Idle blinks, thinking glances, working bobs, waiting shows an amber dot, blocked a red one. Under reduced motion the faces hold still and the dots stay.

```ts title="src/states.ts" source="www/src/examples/persona-avatar/states.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { PersonaAvatar, type PersonaState } from "./ui/uicontext/components/Persona.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({
	row: { display: "flex", flexWrap: "wrap", justifyContent: "center", gap: space.xl },
	cell: { display: "flex", flexDirection: "column", alignItems: "center", gap: space.sm, color: color.muted, fontSize: font.sm },
})

const states: ReadonlyArray<readonly [PersonaState, string]> = [
	["idle", "Idle"], ["thinking", "Thinking"], ["working", "Working"], ["waiting", "Needs you"], ["blocked", "Blocked"], ["done", "Done"],
]

export const States = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.row)).children(states.map(([state, label]) =>
		h.div.key(state).attrs(sx(styles.cell)).children(PersonaAvatar(h, { persona: { shape: "circle", color: "purple" }, size: "lg", state }), label)))
```

### Sizes

16 and 20 for trees and headers, 32 for lists, 44 for a phone's pinned row, 96 for a new agent's preview.

```ts title="src/sizes.ts" source="www/src/examples/persona-avatar/sizes.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { PersonaAvatar } from "./ui/uicontext/components/Persona.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({ row: { display: "flex", alignItems: "flex-end", justifyContent: "center", gap: space.xl } })

export const Sizes = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.row)).children((["xs", "sm", "md", "lg", "xl"] as const).map((size) =>
		PersonaAvatar(h, { persona: { shape: "cloud", color: "green" }, size }).key(size)))
```

## API reference

**Options**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `persona` (required) | `Persona` | — | — |
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | — | 16, 20, 32, 44 or 96 pixels; `md` (32) by default |
| `state` | `"idle" \| "thinking" \| "working" \| "waiting" \| "blocked" \| "done"` | `idle` | What it's doing, shown as motion and a dot; idle by default |
| `label` | `string` | — | A name for screen readers; decorative (hidden) when the agent's name sits beside it |
| `style` | `Style` | — | — |

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/persona-avatar
```

With npm: `npx shadcn@latest add checkfu/uicontext/persona-avatar`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/persona-avatar`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/persona-avatar`.

It writes these files:

- `src/ui/uicontext/components/Persona.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/persona.stylex.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/Persona.ts](https://github.com/checkfu/uicontext/blob/main/src/Persona.ts)
- [src/persona.stylex.ts](https://github.com/checkfu/uicontext/blob/main/src/persona.stylex.ts)

## Used in

- [Bots](https://uicontext.com/blocks/bot-console.md)

## Related

- [Agent Tools](https://uicontext.com/docs/components/agent-tools.md) (`agent-tools`): Lets agents in the browser read the page and act through the same controls people use.
- [Tool Confirmation](https://uicontext.com/docs/components/tool-confirmation.md) (`tool-confirmation`): Asks a person to confirm before an agent's action changes anything.
- [Prompt Template](https://uicontext.com/docs/components/prompt-template.md) (`prompt-template`): Write a prompt with {{variables}} the app fills in: they stand out, unknown ones are flagged, and a preview shows it with samples.
- [Agent Settings](https://uicontext.com/docs/components/agent-settings.md) (`agent-settings`): Edit an agent's name, instructions, tools and model.
- [Computer](https://uicontext.com/docs/components/computer.md) (`computer`): The machine an agent works on: a live view of its screen, full size or as a thumbnail with Take over, and its browser with tabs and an address bar.
- [Agent List](https://uicontext.com/docs/components/agent-list.md) (`agent-list`): Agents listed like conversations, each with its face, last message time and status.
