Persona

Display a person identity: avatar, presence badge and stacked text lines

Usage

Persona displays a person identity: an avatar, an optional presence badge and up to four text lines. Use it in people pickers, contact lists, comment authors and profile headers:

Vitaly Rtishchev
Creator of Mantine
Local time 4:32 PM
Available
Size
Text position
Text alignment
import { Persona } from '@mantine/core';
function Demo() {
  return (
    <Persona
      name="Vitaly Rtishchev"
      secondaryText="Creator of Mantine"
      tertiaryText="Local time 4:32 PM"
      avatar={{ src: image }}
      presence="available"
    />
  );
}

Avatar

avatar prop accepts Avatar props or a custom React node. When it is not set, initials generated from the name prop are displayed. To render Persona without an avatar, use the presenceOnly prop:

Jane Doe
Product designer
Busy, out of office
import { Persona } from '@mantine/core';

function Demo() {
  return (
    <Persona
      name="Jane Doe"
      secondaryText="Product designer"
      presence={{ status: 'busy', outOfOffice: true }}
    />
  );
}

By default, the avatar color is generated from the name prop. Set color in the avatar prop to override it:

import { Avatar, Persona } from '@mantine/core';

function Demo() {
  return (
    <>
      {/* Avatar with an image */}
      <Persona name="Jane Doe" avatar={{ src: 'https://example.com/avatar.png' }} />

      {/* Avatar with initials and a custom color */}
      <Persona name="Jane Doe" avatar={{ color: 'blue' }} />

      {/* Custom avatar node, aria-hidden because the name is rendered next to it */}
      <Persona
        name="Jane Doe"
        avatar={
          <Avatar color="grape" aria-hidden>
            JD
          </Avatar>
        }
      />
    </>
  );
}

Presence

Set presence prop to display a status badge on the avatar. It accepts a status string or an object with outOfOffice and processing modifiers:

Jane Doe
available
Jane Doe
away
Jane Doe
busy
Jane Doe
do-not-disturb
Jane Doe
offline
Jane Doe
out-of-office
Jane Doe
blocked
Jane Doe
unknown
import { Persona, SimpleGrid } from '@mantine/core';

const statuses = [
  'available',
  'away',
  'busy',
  'do-not-disturb',
  'offline',
  'out-of-office',
  'blocked',
  'unknown',
] as const;

function Demo() {
  return (
    <SimpleGrid cols={{ base: 1, xs: 2 }}>
      {statuses.map((status) => (
        <Persona
          key={status}
          name="Jane Doe"
          secondaryText={status}
          presence={status}
          labels={{ [status]: '' }}
        />
      ))}
    </SimpleGrid>
  );
}
import { Persona } from '@mantine/core';

function Demo() {
  return (
    <>
      <Persona name="Jane Doe" presence="available" />
      <Persona name="Jane Doe" presence={{ status: 'available', outOfOffice: true }} />
      <Persona name="Jane Doe" presence={{ status: 'available', processing: true }} />
    </>
  );
}

Presence only

Set presenceOnly prop to display the presence badge inline with the text, without an avatar:

API
All systems operational
Available
Database
Degraded performance
Away
CDN
Major outage
Busy
import { Persona, Stack } from '@mantine/core';

function Demo() {
  return (
    <Stack gap="xs">
      <Persona name="API" secondaryText="All systems operational" presence="available" presenceOnly />
      <Persona name="Database" secondaryText="Degraded performance" presence="away" presenceOnly />
      <Persona name="CDN" secondaryText="Major outage" presence="busy" presenceOnly />
    </Stack>
  );
}

Text lines

Persona renders up to four text lines. Long lines are truncated with an ellipsis:

import { Persona } from '@mantine/core';

function Demo() {
  return (
    <Persona
      name="Vitaly Rtishchev"
      secondaryText="Creator of Mantine"
      tertiaryText="Remote, Berlin"
      quaternaryText="Local time 4:32 PM"
    />
  );
}

Radius

Set radius prop to change the avatar border-radius, the presence badge follows the avatar shape. With compound components, set radius on Persona, not on Persona.Avatar:

Vitaly Rtishchev
radius: 1000px (default)
Available
Vitaly Rtishchev
radius: xl
Available
Vitaly Rtishchev
radius: md
Available
Vitaly Rtishchev
radius: 0
Available
import { Persona, Stack } from '@mantine/core';

function Demo() {
  return (
    <Stack>
      <Persona
        name="Vitaly Rtishchev"
        secondaryText="radius: 1000px (default)"
        avatar={{ src: image }}
        presence="available"
      />
      <Persona
        name="Vitaly Rtishchev"
        secondaryText="radius: xl"
        avatar={{ src: image }}
        presence="available"
        radius="xl"
      />
      <Persona
        name="Vitaly Rtishchev"
        secondaryText="radius: md"
        avatar={{ src: image }}
        presence="available"
        radius="md"
      />
      <Persona
        name="Vitaly Rtishchev"
        secondaryText="radius: 0"
        avatar={{ src: image }}
        presence="available"
        radius={0}
      />
    </Stack>
  );
}

Polymorphic component

Persona is a polymorphic component, set component prop to render it as a link or a button. A button root shrinks to its content, set w="100%" to stretch it:

import { Persona } from '@mantine/core';

function Demo() {
  return (
    <Persona
      component="a"
      href="https://mantine.dev"
      name="Vitaly Rtishchev"
      secondaryText="Open profile"
      presence="available"
    />
  );
}

Compound components

For full control over the layout, use Persona.Avatar, Persona.Presence and Persona.Text compound components instead of the shorthand props. level prop of Persona.Text sets the line importance, 1 is the person name:

Vitaly Rtishchev
Creator of Mantine
Available
import { Persona } from '@mantine/core';

function Demo() {
  return (
    <Persona>
      <Persona.Avatar src={image} />
      <Persona.Presence presence="available" />
      <Persona.Text level={1}>Vitaly Rtishchev</Persona.Text>
      <Persona.Text level={2}>Creator of Mantine</Persona.Text>
    </Persona>
  );
}

Example: people list

Emily Johnson
Product manager
Available
Kevin Gilbert
Frontend developer
Do not disturb
Mary Smith
UX researcher
Busy, out of office
Robert Wolf
Backend developer
Offline
import { Paper, Persona, PersonaPresenceValue, Stack } from '@mantine/core';

const members: { name: string; role: string; image: string; presence: PersonaPresenceValue }[] = [
  { name: 'Emily Johnson', role: 'Product manager', image: image1, presence: 'available' },
  { name: 'Kevin Gilbert', role: 'Frontend developer', image: image2, presence: 'do-not-disturb' },
  { name: 'Mary Smith', role: 'UX researcher', image: image3, presence: { status: 'busy', outOfOffice: true } },
  { name: 'Robert Wolf', role: 'Backend developer', image: image4, presence: 'offline' },
];

function Demo() {
  return (
    <Paper withBorder p="md" radius="md">
      <Stack gap="lg">
        {members.map((person) => (
          <Persona
            key={person.name}
            name={person.name}
            secondaryText={person.role}
            avatar={{ src: person.image }}
            presence={person.presence}
          />
        ))}
      </Stack>
    </Paper>
  );
}

Accessibility

  • The status is announced after the name and text lines, for example "Jane Doe, Product designer, Available"
  • Statuses are announced in English by default. Use labels prop to translate them:
import { Persona } from '@mantine/core';

function Demo() {
  return (
    <Persona
      name="Jane Doe"
      presence={{ status: 'busy', outOfOffice: true }}
      labels={{
        available: 'Verfügbar',
        away: 'Abwesend',
        busy: 'Beschäftigt',
        outOfOffice: 'nicht im Büro',
      }}
    />
  );
}
  • When a text line already displays the status, set that status label to an empty string, for example labels={{ available: '' }}, so it is not announced twice
  • The avatar is hidden from assistive technologies, because the name is rendered next to it. Set alt in the avatar prop when the avatar is displayed without text.
  • A custom node passed to the avatar prop is not hidden, add aria-hidden to it if it is decorative

Styles API

Persona supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.

Vitaly Rtishchev
Creator of Mantine
Local time 4:32 PM
Available

Component Styles API

Hover or focus a selector to highlight its elements

/*
 * Hover or focus a selector
 * to outline its elements
 */