Dev Helpers
← Back

Initials avatar

Import and render <InitialsAvatar /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/InitialsAvatar.tsx

export default function InitialsAvatar({
  text = "Studio notes from the harbour",
}: { text?: string } = {}) {
  const initials = text
    .trim()
    .split(/\s+/)
    .slice(0, 2)
    .map((w) => w[0])
    .join("")
    .toUpperCase();
  return <abbr title={text}>{initials}</abbr>;
}