Skip to content

Avatar

A circular profile image component with optional placeholder initials.

vue
<script setup lang="ts">
import { Avatar } from '@/components/kuro/avatar';
</script>

<template>
  <Avatar initials="BN" />
</template>

Installation

bash
npx kuro-ui add avatar
bash
npx github:Bartek-Nowak/Kuro add avatar

Variants and Sizes

The Avatar component supports several color variants and three sizes.

VariantDescription
defaultNeutral gray background and text
successGreen background and text
warningYellow background and text
errorRed background and text
infoBlue background and text
SizeDescription
smSmall avatar (32x32)
mdMedium avatar (48x48) (default)
lgLarge avatar (64x64)

Props

PropTypeDefaultDescription
srcstringURL of the profile image
altstringAlt text for the image and accessibility label
initialsstringPlaceholder initials shown if image is missing
sizestringmdSize of the avatar (sm, md, lg)
variantstringdefaultColor variant
classstringAdditional Tailwind CSS classes

Usage

The component displays an image if src is provided. If not, it falls back to showing uppercase initials or a question mark (?).

The container has role img with an accessible label provided via alt prop or defaults to "Avatar".

Usage Example

vue
<template>
    <Avatar src="https://randomuser.me/api/portraits/women/44.jpg" alt="User photo" />
    <Avatar initials="BN" size="sm" />
    <Avatar initials="JS" size="lg" />
    <Avatar size="md" />
</template>