Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

Avatar

avatar

Displays a user image with fallback content.

Usage

Picture with fallback

src Displays the image if loading is successful; falls back to fallback (initial letter/text) if failed or omitted.

ZSHu
tsx
<>
  <Avatar src="/demo/avatar-12.jpg" alt="demo" fallback="ZS" />
  <Avatar fallback="Hu" />
</>

Size

size provides sm / md / lg / xl / 2xl in five diameters.

SMLXL2X
tsx
<>
  <Avatar size="sm" fallback="S" />
  <Avatar size="md" fallback="M" />
  <Avatar size="lg" fallback="L" />
  <Avatar size="xl" fallback="XL" />
  <Avatar size="2xl" fallback="2X" />
</>

Accent and ring

tone="brand" uses the accent's subtle background with accent text; ring adds a 2px outer ring whose color follows tone, and inside a primary card the neutral ring turns translucent white automatically.

LinLin
A
tsx
<Avatar tone="brand" ring fallback="Lin" />
<Card variant="primary">
  <Avatar ring src="/demo/avatar-12.jpg" alt="Abel" fallback="A" />
</Card>

When to use

Use Avatar for one person's image, with initials or other fallback content when the image is missing or fails. Use [User] for an avatar with a name and description, or AvatarCircles for an overlapping group.

Import

ts
import { Avatar } from "@hulianui/ui"

Props

NameTypeDefaultDescription
size"sm" | "md" | "lg" | "xl" | "2xl""md"Preset circular diameter: 32 / 40 / 48 / 64 / 96px.
srcstring-Image URL; failures reveal fallback.
altstring-Alternative image text.
tone"neutral" | "brand""neutral"Placeholder background: neutral is a neutral gray; brand uses the accent's subtle background with accent text, for the brand's, system's, or AI's own avatar, or initials that should carry the theme color. A loaded image covers it.
ringbooleanfalseA 2px outer ring whose color follows tone (border for neutral, the accent's subtle border for brand). Use it over colored backgrounds or photos, or when stacking avatars. Inside a primary card the neutral ring becomes translucent white automatically.
classNamestring-Custom class name.

Slots

SlotTypeDescription
fallbackReactNodeContent shown without a working image, usually initials.

Pitfalls

  • Base UI reveals fallback after a missing or failed src; provide it to avoid an empty avatar.
  • size accepts only sm, md, and lg. Override dimensions through className for a custom size.

Related

Sparkline · ImageViewer · LiveProductCard · DiffStat · ScoreRing · Badge

Playground

ZS
<Avatar size="md" src="/demo/avatar-12.jpg" fallback="ZS" />
PreviousAnnotationData DisplayNextAvatarCircles

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Slots
    • Pitfalls
    • Related
  • Playground