Pallas UI
DocsComponents
Core Concepts
    • Introduction
    • Getting Started
    • Theming
    • Color Tokens
    • Spacing & Sizing
    • Layout Guide
    • AspectRatio
    • Box
    • Flex
    • Grid
    • Shapes
Previews
    • Accordion
    • Alert
    • Avatar
    • Badge
    • Breadcrumb
    • Button
    • Carousel
    • Checkbox
    • Combobox
    • Command
    • Date Picker
    • Form
    • Input
    • Input OTP
    • Label
    • MenuBar
    • Modal
    • Popover
    • Progress
    • Radio Group
    • Segmented
    • Select
    • Separator
    • Sheet
    • Sidebar
    • Skeleton
    • Slider
    • Spinner
    • Steps
    • Switch
    • Tabs
    • Textarea
    • Toast
    • Tooltip
    • Typography
  1. Components
  2. Avatar

Avatar

An image element with a fallback for representing the user.

ARAR

Installation

Install the following dependencies

npm install @radix-ui/react-avatar

Copy and paste the following code into your project

'use client'
import { type Assign, type WithFixedClassName, createStyleContext } from '@pallas-ui/style-context'
import * as RadixAvatar from '@radix-ui/react-avatar'
import { type AvatarVariantProps, avatar } from '@styled-system/recipes'
import type { ComponentProps, JsxStyleProps } from '@styled-system/types'
import type * as React from 'react'
 
const { withProvider, withContext } = createStyleContext(avatar)
 
export type RootProps = WithFixedClassName<ComponentProps<typeof RadixAvatar.Root>>
 
export const Root = withProvider<
  React.ComponentRef<typeof RadixAvatar.Root>,
  Assign<RootProps, AvatarVariantProps & JsxStyleProps>
>(RadixAvatar.Root, 'root')
 
export const Image = withContext<
  React.ComponentRef<typeof RadixAvatar.Image>,
  Assign<ComponentProps<typeof RadixAvatar.Image>, JsxStyleProps>
>(RadixAvatar.Image, 'image')
 
export const Fallback = withContext<
  React.ComponentRef<typeof RadixAvatar.Fallback>,
  Assign<ComponentProps<typeof RadixAvatar.Fallback>, JsxStyleProps>
>(RadixAvatar.Fallback, 'fallback')
 
const Avatar = {
  Root,
  Image,
  Fallback,
}
 
export default Avatar

Update the import paths to match your project setup

Usage

import Avatar from '@/components/ui/avatar'
 
<Avatar.Root size="md" shape="circle">
  <Avatar.Image src="https://github.com/nanopx.png" alt="@nanopx" />
  <Avatar.Fallback>NP</Avatar.Fallback>
</Avatar.Root>

Examples

Shapes

The Avatar component supports two shapes: circle (default) and square.

CRSQ

Sizes

Available sizes: sm (32px), md (40px), lg (48px), and xl (56px). Default is md.

SMMDLGXL

Fallbacks

The fallback is displayed when the image fails to load or when no image is provided.

AKJD

API Reference

Root Props

PropTypeDefaultDescription
size'sm' | 'md' | 'lg' | 'xl''md'Controls the size of the avatar
shape'circle' | 'square''circle'Controls the shape of the avatar

Built with ❤️ by the carbonteq team. The source code is available on GitHub.

© 2025 Pallas UI. All rights reserved.