---
title: "Persona · Base UI — StyleX Blocks"
description: "Avatar with name, secondary label, and a presence badge or ring, from 2xs to 2xl."
url: "https://stylexblocks.com/components/base-ui/persona/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Persona

Avatar with name, secondary label, and a presence badge or ring, from 2xs to 2xl.

- Behavior engine: Base UI
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/persona.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/persona.md)
- Category: Display
- Variants: badge, ring
- Sizes: 2xs, xs, sm, md, lg, xl, 2xl
- HTML page: https://stylexblocks.com/components/base-ui/persona/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style base-ui
```

Then add the item as source you own:

```sh
npx stylexblocks add persona
```

Equivalent: `npx shadcn add @stylexblocks/persona`. Registry item JSON: https://stylexblocks.com/r/base-ui/persona.json

## Usage

```tsx
import { Persona } from "#components/ui/base-ui/persona.tsx";
import { Avatar } from "#components/ui/base-ui/avatar.tsx";

export function Example() {
  return (
    // variant/size resolve once on Root; parts inherit them via context and
    // expose data-* attributes. Nest Persona.Presence inside your avatar —
    // the badge sizes from the avatar's --avatar-size and colors from
    // --persona-presence (set it to a semantic presence token).
    <Persona.Root variant="badge" size="md" style={styles.online}>
      <Avatar.Root shape="full">
        <Avatar.Fallback>SJ</Avatar.Fallback>
        <Persona.Presence />
      </Avatar.Root>
      <Persona.Details>
        <Persona.Label>Sara Jansen</Persona.Label>
        <Persona.SecondaryLabel>Product Manager</Persona.SecondaryLabel>
        <Persona.TertiaryLabel>Amsterdam · 09:41</Persona.TertiaryLabel>
      </Persona.Details>
    </Persona.Root>
  );
}

// styles.online = { "--persona-presence": semanticColors.presenceOnline }
// secondary/tertiary labels hide themselves at the smaller sizes
```

## Source

`components/ui/base-ui/persona.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createSlotRecipeContext } from "#lib/base-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'
import { radii } from '@stylexblocks/ui/tokens/radii.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const personaRoot = stylex.create({
  base: {
    '--presence-border-color': 'var(--bg-currentcolor)',
    '--persona-presence': semanticColors.presenceOffline,
    display: 'flex',
    flexDirection: 'row',
    alignItems: 'center',
  },
})

const personaDetails = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    minWidth: 0,
    lineHeight: 1.375,
  },
})

const personaDetailsSizes = stylex.create({
  '2xs': {
    marginInlineStart: spacing._1,
  },
  xs: {
    marginInlineStart: spacing._1_5,
  },
  sm: {
    marginInlineStart: spacing._2,
  },
  md: {
    marginInlineStart: spacing._2,
  },
  lg: {
    marginInlineStart: spacing._3,
  },
  xl: {
    marginInlineStart: spacing._4,
  },
  '2xl': {
    marginInlineStart: spacing._4,
  },
})

const personaLabel = stylex.create({
  base: {
    overflow: 'hidden',
    whiteSpace: 'nowrap',
    textOverflow: 'ellipsis',
    minWidth: 0,
    color: semanticColors.fg,
  },
})

const personaLabelSizes = stylex.create({
  '2xs': {
    fontSize: fontSizes.xs,
  },
  xs: {
    fontSize: fontSizes.xs,
  },
  sm: {
    fontSize: fontSizes.sm,
  },
  md: {
    fontSize: fontSizes.sm,
  },
  lg: {
    fontSize: fontSizes.md,
  },
  xl: {
    fontSize: fontSizes.lg,
  },
  '2xl': {
    fontSize: fontSizes.xl,
  },
})

const personaSecondaryLabel = stylex.create({
  base: {
    overflow: 'hidden',
    whiteSpace: 'nowrap',
    textOverflow: 'ellipsis',
    minWidth: 0,
    color: `color-mix(in oklch, ${semanticColors.fg} 60%, transparent)`,
  },
})

const personaSecondaryLabelSizes = stylex.create({
  '2xs': {
    display: 'none',
  },
  xs: {
    display: 'none',
  },
  sm: {
    fontSize: fontSizes.xs,
  },
  md: {
    fontSize: fontSizes.xs,
  },
  lg: {
    fontSize: fontSizes.sm,
  },
  xl: {
    fontSize: fontSizes.md,
  },
  '2xl': {
    fontSize: fontSizes.lg,
  },
})

const personaTertiaryLabel = stylex.create({
  base: {
    overflow: 'hidden',
    whiteSpace: 'nowrap',
    textOverflow: 'ellipsis',
    minWidth: 0,
    color: `color-mix(in oklch, ${semanticColors.fg} 60%, transparent)`,
  },
})

const personaTertiaryLabelSizes = stylex.create({
  '2xs': {
    display: 'none',
  },
  xs: {
    display: 'none',
  },
  sm: {
    display: 'none',
  },
  md: {
    display: 'none',
  },
  lg: {
    fontSize: fontSizes.sm,
  },
  xl: {
    fontSize: fontSizes.md,
  },
  '2xl': {
    fontSize: fontSizes.lg,
  },
})

const personaPresence = stylex.create({
  base: {},
})

const personaPresenceVariants = stylex.create({
  badge: {
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
    position: 'absolute',
    bottom: 0,
    right: 0,
    width: 'calc(var(--avatar-size) / 3)',
    height: 'calc(var(--avatar-size) / 3)',
    transform: 'translate(12%, 12%)',
    borderWidth: '0.10em',
    borderRadius: '50%',
    borderColor: 'var(--presence-border-color)',
    backgroundColor: 'var(--persona-presence)',
  },
  ring: {
    outlineWidth: '2px',
    outlineColor: 'var(--persona-presence)',
    outlineOffset: '2px',
    outlineStyle: 'solid',
    borderRadius: radii.full,
    position: 'absolute',
    inset: 0,
  },
})

export type PersonaSize = keyof typeof personaDetailsSizes

export type PersonaVariant = keyof typeof personaPresenceVariants

// defineSlotRecipe validates the shape at compile time: default values must
// exist in the axis maps, and slot keys must be `styles` or a declared axis
const personaSlotRecipe = defineSlotRecipe({
  slots: {
    root: { styles: personaRoot },
    details: { styles: personaDetails, sizes: personaDetailsSizes },
    label: { styles: personaLabel, sizes: personaLabelSizes },
    secondaryLabel: { styles: personaSecondaryLabel, sizes: personaSecondaryLabelSizes },
    tertiaryLabel: { styles: personaTertiaryLabel, sizes: personaTertiaryLabelSizes },
    presence: { styles: personaPresence, variants: personaPresenceVariants },
  },
  defaultVariants: { size: "md", variant: "badge" },
});

/**
 * Persona — recipe and component colocated in one file. `<Persona.Root
 * variant size>` resolves the recipe once and every part inherits it through
 * context; each part composes via `render`. Place your avatar (any
 * positioned element) as the first child and nest `Persona.Presence` inside
 * it — the badge sizes off the avatar's `--avatar-size` and both variants
 * color from `--persona-presence` (set it to a semantic presence token).
 * Secondary/tertiary labels hide themselves at the smaller sizes.
 */
const { withProvider, withContext } = createSlotRecipeContext(personaSlotRecipe);

export const Persona = {
  Root: withProvider("div", "root", "PersonaRoot"),
  Details: withContext("div", "details", "PersonaDetails"),
  Label: withContext("span", "label", "PersonaLabel"),
  SecondaryLabel: withContext("span", "secondaryLabel", "PersonaSecondaryLabel"),
  TertiaryLabel: withContext("span", "tertiaryLabel", "PersonaTertiaryLabel"),
  Presence: withContext("span", "presence", "PersonaPresence"),
};
```
