Skip to content

Avatar

An element for representing a user.

import { Avatar, AvatarImage, AvatarFallback } from '@klnjs/react-avatar'
import classes from './avatar.module.css'
import image from './react.svg'
export default () => (
<Avatar className={classes.avatar}>
<AvatarImage src={image.src} className={classes.image} />
<AvatarFallback className={classes.fallback}>RK</AvatarFallback>
</Avatar>
)

Features

  • Image loading status handling.

  • Fallback to any content imaginable.

  • Delay fallback to avoid flickering.

Installation

Terminal window
bun install @klnjs/react-avatar

Definitions

/>

Components

Avatar

Contains all the parts of an avatar.

PropTypeDefault
asChild
boolean
false
onStatusChange
(status: AvatarStatus) => void
-

Image

Used to render the image. The image is hidden until it has loaded. Use the root property onStatusChange, to listen to the image status.

PropTypeDefault
asChild
boolean
false
src
string
-

Fallback

Used to render the fallback while the image is loading, or when an error occurs. To prevent flickering between image and fallback use the delay property, to delay rendering of the fallback whilst image is loading.

PropTypeDefault
asChild
boolean
false
delay
number
-