Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Core

Avatar

Picture of a person or business. Without src it shows the initials of name.

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

Example

Code
import { Avatar, Stack } from "@stylhero/ui";

function AvatarExample() {
  return (
    <Stack direction="row" gap={3} align="center">
      <Avatar name="Ana López" size="sm" />
      <Avatar name="Ben Ortiz" />
      <Avatar name="Acme Hardware" shape="rounded" size="lg" />
    </Stack>
  );
}

Props

PropTypeDefaultDescription
name required string - Used for the initials and the image's alt text.
children ReactNode - Your own image element instead of src, e.g. next/image.
shape "circle" | "rounded" "circle" "rounded" is a soft square, for businesses and logos.
size "sm" | "md" | "lg" | "xl" "md"
src string -

Also takes every <span> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.

Accessibility

  • name is the image's alt text, or the label of the initials.

Generated from src/components/Avatar.tsx. Something wrong or missing? Open an issue.