import { Avatar } from "@replicas/ui";

const members = [
  { name: "Leah Torres", initials: "LT", src: "https://images.unsplash.com/photo-1543610892-0b1f7e6d8ac1?w=128&h=128&dpr=2&q=80" },
  { name: "Karri Saarinen", initials: "KS" },
  { name: "Tuomas Artman", initials: "TA" },
  { name: "Jori Lallo", initials: "JL" },
];

export default function AvatarDemo() {
  return (
    <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 16 }}>
      <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
        {(["small", "medium", "large"] as const).map((size) => (
          <Avatar.Root key={size} size={size}>
            <Avatar.Image src={members[0].src} alt={members[0].name} />
            <Avatar.Fallback>{members[0].initials}</Avatar.Fallback>
          </Avatar.Root>
        ))}
      </div>
      <div style={{ display: "flex", alignItems: "center", gap: 4 }}>
        {members.map((member) => (
          <Avatar.Root key={member.name} size="large" title={member.name}>
            {member.src ? <Avatar.Image src={member.src} alt={member.name} /> : null}
            <Avatar.Fallback>{member.initials}</Avatar.Fallback>
          </Avatar.Root>
        ))}
      </div>
    </div>
  );
}

Examples

Sizes

RSRSRSRSRS
<Avatar.Root size="small-200">
  <Avatar.Fallback>RS</Avatar.Fallback>
</Avatar.Root>
<Avatar.Root size="small">
  <Avatar.Fallback>RS</Avatar.Fallback>
</Avatar.Root>
<Avatar.Root size="base">
  <Avatar.Fallback>RS</Avatar.Fallback>
</Avatar.Root>
<Avatar.Root size="large">
  <Avatar.Fallback>RS</Avatar.Fallback>
</Avatar.Root>
<Avatar.Root size="large-200">
  <Avatar.Fallback>RS</Avatar.Fallback>
</Avatar.Root>

Prompt

Copy Prompt hands your agent everything it needs to build the Avatar in the Shopify style: the measured tokens, the CSS and the structure.

Show Prompt
# Shopify Avatar

An easily stylable avatar component.

Build a Avatar in this project that looks and behaves like Shopify's. Measured from the running Shopify app (admin.shopify.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or [Base UI](https://base-ui.com/react/components/avatar) if it has none.

Fidelity: Measured from Shopify admin Settings > General, store avatar. Only the base size has a reference. Background and text colour are ignored because Polaris picks them from a hash of the initials. Other sizes follow the Polaris avatar scale.

## Variants

- `size`: `small-200`, `small`, `base`, `large`, `large-200`

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--p-border-radius-avatar` | `clamp(.375rem, round(30%, .125rem), .75rem)` | `clamp(.375rem, round(30%, .125rem), .75rem)` |
| `--p-border-radius-corner-shape` | `superellipse(1.333)` | `superellipse(1.333)` |
| `--p-color-avatar-bg-fill` | `#a6a6a6` | `#b5b5b5` |
| `--p-color-avatar-text-on-bg-fill` | `#101010` | `#fff` |
| `--p-font-family-sans` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` |
| `--p-font-weight-regular` | `400` | `400` |
| `--p-height-500` | `1.25rem` | `1.25rem` |
| `--p-height-600` | `1.5rem` | `1.5rem` |
| `--p-height-700` | `1.75rem` | `1.75rem` |
| `--p-height-800` | `2rem` | `2rem` |
| `--p-height-1000` | `2.5rem` | `2.5rem` |

## CSS

Scoped under `[data-style="shopify"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="shopify"] {
  .ui-avatar {
    --avatar-size: var(--p-height-700);

    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: var(--avatar-size);
    height: var(--avatar-size);
    overflow: hidden;
    vertical-align: middle;
    border-radius: var(--p-border-radius-avatar);
    corner-shape: var(--p-border-radius-corner-shape);
    background-color: var(--p-color-avatar-bg-fill);
    color: var(--p-color-avatar-text-on-bg-fill);
    font-family: var(--p-font-family-sans);
    font-size: calc(var(--avatar-size) * 0.4);
    font-weight: var(--p-font-weight-regular);
    line-height: 1;
    user-select: none;
  }

  .ui-avatar[data-size="small-200"] {
    --avatar-size: var(--p-height-500);
  }

  .ui-avatar[data-size="small"] {
    --avatar-size: var(--p-height-600);
  }

  .ui-avatar:is([data-size="base"], [data-size="medium"]) {
    --avatar-size: var(--p-height-700);
  }

  .ui-avatar[data-size="large"] {
    --avatar-size: var(--p-height-800);
  }

  .ui-avatar[data-size="large-200"] {
    --avatar-size: var(--p-height-1000);
  }

  .ui-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .ui-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-transform: uppercase;
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Avatar as BaseAvatar } from "@base-ui/react/avatar";

const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);

type RootProps = Omit<BaseAvatar.Root.Props, "className"> & {
  className?: string;
  size?: string;
  shape?: string;
};

function Root({ className, size = "medium", shape, ...props }: RootProps) {
  return <BaseAvatar.Root className={join("ui-avatar", className)} data-size={size} data-shape={shape} {...props} />;
}

function Image({ className, ...props }: Omit<BaseAvatar.Image.Props, "className"> & { className?: string }) {
  return <BaseAvatar.Image className={join("ui-avatar-image", className)} {...props} />;
}

function Fallback({ className, ...props }: Omit<BaseAvatar.Fallback.Props, "className"> & { className?: string }) {
  return <BaseAvatar.Fallback className={join("ui-avatar-fallback", className)} {...props} />;
}

export const Avatar = {
  Root,
  Image,
  Fallback,
};
```

## Example

```tsx
import { Avatar } from "@replicas/ui";

const members = [
  { name: "Leah Torres", initials: "LT", src: "https://images.unsplash.com/photo-1543610892-0b1f7e6d8ac1?w=128&h=128&dpr=2&q=80" },
  { name: "Karri Saarinen", initials: "KS" },
  { name: "Tuomas Artman", initials: "TA" },
  { name: "Jori Lallo", initials: "JL" },
];

export default function AvatarDemo() {
  return (
    <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 16 }}>
      <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
        {(["small", "medium", "large"] as const).map((size) => (
          <Avatar.Root key={size} size={size}>
            <Avatar.Image src={members[0].src} alt={members[0].name} />
            <Avatar.Fallback>{members[0].initials}</Avatar.Fallback>
          </Avatar.Root>
        ))}
      </div>
      <div style={{ display: "flex", alignItems: "center", gap: 4 }}>
        {members.map((member) => (
          <Avatar.Root key={member.name} size="large" title={member.name}>
            {member.src ? <Avatar.Image src={member.src} alt={member.name} /> : null}
            <Avatar.Fallback>{member.initials}</Avatar.Fallback>
          </Avatar.Root>
        ))}
      </div>
    </div>
  );
}
```

## Foundations

The rest of the Shopify style, as a skill: https://replicas.raphaelsalaja.com/skills/shopify/SKILL.md