Svelte Avatar - Bitblue

Use the avatar component to show a visual representation of a user profile using an image element or SVG object based on multiple styles and sizes

The avatar component can be used as a visual identifier for a user profile on your website. Adjust styles and sizes with Tailwind utility classes and the component props below.

Setup

Import Avatar. If you are using the user dropdown, import Dropdown, DropdownHeader, DropdownItem. If you are using tooltip for avatar import Tooltip.

<script>
	import { Avatar, Dropdown, DropdownHeader, DropdownItem, Tooltip } from '.';
</script>

Default avatar

Use this example to create a circle and rounded avatar on an image element.

<script>
	import { Avatar } from '.';
</script>

<div class="flex space-x-4 rtl:space-x-reverse">
	<Avatar src="/images/profile-picture-2.webp" />
	<Avatar src="/images/profile-picture-2.webp" cornerStyle="rounded" />
</div>

Icon avatar

<script>
	import { Avatar } from '.';
</script>

<Avatar>
	<iconify-icon icon="ph:seal-check-fill"></iconify-icon>
</Avatar>

Custom dot

<script>
	import { Avatar, Indicator } from '.';
</script>

<Avatar src="/images/profile-picture-3.webp">
	{#snippet indicator()}
		<Indicator color="gray" border size="xl" placement="top-right">
			<iconify-icon icon="ph:seal-check-fill"></iconify-icon>
		</Indicator>
	{/snippet}
</Avatar>

Bordered

You can apply a border around the avatar component.

You can use the ring-{color} class from Tailwind CSS to modify ring color.

<script>
	import { Avatar } from '.';
</script>

<Avatar src="/images/profile-picture-2.webp" border />
<Avatar src="/images/profile-picture-2.webp" border class="ring-red-400 dark:ring-red-300" />

Placeholder

When there is no custom image available a placeholder is displayed.

<script>
	import { Avatar } from '.';
</script>

<Avatar />
<Avatar cornerStyle="rounded" />
<Avatar border />
<Avatar cornerStyle="rounded" border />

Placeholder initials

This example can be used to show the initials of the user’s first and last name as a placeholder when no profile picture is available.

JL
<script>
	import { Avatar } from '.';
</script>

<Avatar>JL</Avatar>

Dot indicator

Use a dot element relative to the avatar component as an indicator for the user (eg. online or offline status).

<script>
	import { Avatar } from '.';
</script>

<Avatar src="/images/profile-picture-3.webp" dot={{ color: 'red' }} />
<Avatar
	src="/images/profile-picture-3.webp"
	dot={{ placement: 'top-right', color: 'red' }}
	cornerStyle="rounded"
/>
<Avatar src="/images/profile-picture-5.webp" dot={{ placement: 'bottom-right', color: 'green' }} />
<Avatar
	src="/images/profile-picture-5.webp"
	dot={{ placement: 'bottom-right' }}
	cornerStyle="rounded"
/>

<Avatar dot={{}} />

Stacked

Use this example if you want to stack a group of users by overlapping the avatar components.

<script>
	import { Avatar } from '.';
</script>

<div class="mb-5 flex">
	<Avatar src="/images/profile-picture-1.webp" stacked />
	<Avatar src="/images/profile-picture-2.webp" stacked />
	<Avatar src="/images/profile-picture-3.webp" stacked />
	<Avatar stacked />
</div>
<div class="flex">
	<Avatar src="/images/profile-picture-1.webp" stacked />
	<Avatar src="/images/profile-picture-2.webp" stacked />
	<Avatar src="/images/profile-picture-3.webp" stacked />
	<Avatar stacked href="/" class="bg-gray-700 text-sm text-white hover:bg-gray-600">+99</Avatar>
</div>

User dropdown

Use this example if you want to show a dropdown menu when clicking on the avatar component.

<script>
	import { Avatar, Dropdown, DropdownHeader, DropdownItem, DropdownGroup } from '.';
</script>

<Avatar
	id="user-drop"
	src="/images/profile-picture-3.webp"
	class="cursor-pointer"
	dot={{ color: 'green' }}
/>
<Dropdown triggeredBy="#user-drop">
	<DropdownHeader>
		<span class="block text-sm">Bonnie Green</span>
		<span class="block truncate text-sm font-medium">name@flowbite.com</span>
	</DropdownHeader>
	<DropdownGroup>
		<DropdownItem>Dashboard</DropdownItem>
		<DropdownItem>Settings</DropdownItem>
		<DropdownItem>Earnings</DropdownItem>
	</DropdownGroup>
	<DropdownGroup>
		<DropdownItem>Sign out</DropdownItem>
	</DropdownGroup>
</Dropdown>

Sizes

You can set size property to preset values of xs | sm | md | lg | xl. Custom size can be achieved by adding any of the Tailwind Css size classes like w-[x] h-[x].

Preset values are equivalents of:

SizeClasses
xsw-6 h-6
smw-8 h-8
mdw-10 h-10
lgw-20 h-20
xlw-36 h-36
<script>
	import { Avatar } from '.';
</script>

<div class=" flex flex-wrap justify-center space-x-4 rtl:space-x-reverse">
	<Avatar src="/images/profile-picture-3.webp" size="xs" />
	<Avatar src="/images/profile-picture-3.webp" size="sm" />
	<Avatar src="/images/profile-picture-3.webp" size="md" />
	<Avatar src="/images/profile-picture-3.webp" size="lg" />
	<Avatar src="/images/profile-picture-3.webp" size="xl" />
	<Avatar src="/images/profile-picture-3.webp" class="h-28 w-28" />
</div>

Composition notes

  • Pass src for an image; omit it to show the default user SVG or custom children (initials, icons).
  • dot accepts Indicator props (placement, color, size) for online-status dots; use indicator for fully custom overlays.
  • With href, the root renders as an anchor; otherwise a focusable div when clickable.

Props

AvatarProps

PropTypeDefaultDescription
srcstring—Image URL
altstring—Image alt text
sizexs | sm | md | lg | xlmdPreset dimensions
cornerStylecircular | roundedcircularShape
borderbooleanfalseRing border
stackedbooleanfalseOverlap for avatar stacks
hrefstring—Render as link
targetstring—Link target
dotobject (Indicator props)—Status dot; merges defaults placement: 'top-right', color: 'gray', size: 'lg'
indicatorSnippet—Custom overlay indicator
childrenSnippet—Fallback content (no src)
onclick() => void—Click handler
classClassValue—Extra classes
…restdiv attrs—Forwarded to the root

Snippets

SnippetDescription
childrenInitials / custom fallback
indicatorCustom status overlay

© 2026 Bitblue is a registered trademark. All Rights Reserved.