Skip to content

KAvatar ​

Avatars can be used to represent people or objects. It supports images, Icons, or characters.

Install ​

bash
pnpm add @ikun-ui/avatar
bash
yarn add @ikun-ui/avatar
bash
npm install @ikun-ui/avatar

Basic usage ​

Use size and radius prop to set avatar's size and radius.

Types ​

It supports images, Icons, or characters.

Fallback ​

fallback when image load error.

Fit Container ​

Set how the image fit its container for an image avatar, same as object-fit .

Avatar Props ​

NameTypeDefaultDescription
iconstring''The class name of the icon, following the unocss standard.
srcstring''the source of the image for an image avatar..
srcSetstring''native attribute srcset of image avatar.
altstring''native attribute alt of image avatar.
fitfill / contain / cover / none / scale-downcoverset how the image fit its container for an image avatar.
sizestring / number50pxavatar size, the default unit is px.
radiusstring / number4pxavatar radius, the default unit is px.
clsstring''Additional class for component
attrsRecord<string, string>{}Additional attributes

Avatar Events ​

NameDescriptionType
errortrigger when image load error.(event: CustomEvent)=> void

Avatar Slots ​

NameDescription
defaultCustomize default content

MIT Licensed