Skip to content

Avatar

A person's picture with their initial when there is none (or it fails to load).

Base UI1.1 kB gzipSource Registry JSON

Avatar playground

Props

size

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/avatar.json

The CLI writes components/ikada/avatar.tsx and merges the ikada theme into your CSS. Or take it from the package: import { Avatar } from "@sproutboat/ikada";

Usage

import { Avatar } from "@/components/ikada/avatar";

<Avatar name="robin" size="lg" />

Examples

Sizes

24, 32 and 48px. The first letter of the name stands in when there is no picture.

Next to a name

Decorative beside a visible name: the initial is hidden from screen readers.
heron

Props

AvatarProps
PropTypeDescription
srcstring | nullThe picture URL. A missing or broken image falls back to the initial.
namerequiredstringWhose avatar it is. Becomes the image alt text; its first letter is the fallback.
size"sm" | "md" | "lg"24px (sm), 32px (md, the default) or 48px (lg).
classNamestringClasses merged onto the root element, after ikada's own.
styleCSSProperties | ((state: AvatarRootState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, AvatarRootState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

Also takes every prop of Omit<ComponentProps<typeof BaseAvatar.Root>, "children" | "className">.

Source: src/components/avatar.tsx