Command palette

@yasinsensoy/web

Web · Components

Avatar

Profile photo.

7 exports

Live example

Preview

Code

import { Avatar } from "@yasinsensoy/web";

<Avatar src="https://github.com/yasinsensoy.png" name="Yasin Şensoy" status="online" tooltip="Yasin Şensoy · Online" />

Events

  1. Events appear here when you interact with the preview.

AvatarGroup: the rest as +N; names appear on hover

AYMK+2

Import

import { Avatar, AvatarGroup } from "@yasinsensoy/web";

Avatar

componentClient component

Profile photo. Shows the initials of name until the photo loads or if it fails, so the layout doesn't shift and no broken image appears.

Avatar({ src, name, icon, fallback, size, shape, status: presence, effect, tooltip, className, ...props }: AvatarProps): ReactNode

Examples

<Avatar src="/jane.jpg" name="Jane Doe" />
<Avatar name="John Smith" size="lg" status="online" />
<Avatar icon="user" size="sm" />
<Avatar src="/john.jpg" name="John Smith" tooltip="John Smith · Design" />

AvatarGroup

componentClient component

Overlapping avatar group (e.g. the people on a project). On hover the person's name shows as a tooltip; the "+3" summary's tooltip lists the hidden people's names.

AvatarGroup({ items, max, size, className, ...props }: AvatarGroupProps): JSX.Element

Examples

<AvatarGroup max={3} items={[{ name: "Jane", src: "/j.jpg" }, { name: "John" }, …]} />

Avatar size: xs 24 px, sm 32 px, md 40 px, lg 48 px, xl 64 px.

type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl"

Status dot at the avatar's corner.

type AvatarStatus = "online" | "away" | "busy" | "offline"

AvatarProps

interface

Props of the Avatar component.

Extends: Omit<ComponentProps<"span">, "children">

NameTypeDefaultDescription
src?string | nullPhoto URL. If it fails to load, initials or an icon appear instead.
name?stringThe person's name. Becomes the photo's screen reader name, and its initials are shown when there is no photo.
icon?IconPropIcon shown when there is no photo or name: a name or an element.
fallback?ReactNodeCustom content shown instead of initials when there is no photo.
size?AvatarSize"md"
shape?"circle" | "square""circle"
status?AvatarStatusStatus dot at the bottom right corner.
effect?EffectPropEffect or effects (e.g. "ripple", ["lift", "beam"]). Defaults to UIProvider appearance.defaults.avatar.effect. See BuiltinEffect.
tooltip?TooltipPropTooltip shown on hover, focus or long press (e.g. tooltip={name}). When it is text other than the name, the avatar also becomes keyboard focusable. See TooltipProp.

A person inside an AvatarGroup.

NameTypeDescription
src?string | nullPhoto URL.
namestringThe person's name.
tooltip?TooltipPropTooltip. Shows the name when omitted; turned off with false.

Props of the AvatarGroup component.

Extends: Omit<ComponentProps<"div">, "children">

NameTypeDefaultDescription
itemsreadonly AvatarGroupItem[]People to show.
max?numberMaximum number of avatars to show; the rest is summarized as "+3".
size?AvatarSize"md"