Avatar - Ant Design

  • Components Overview
  • Changelogv6.1.2
  • General
    • Button
    • FloatButton
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
    • Grid
    • Layout
    • Masonry6.0.0
    • Space
    • Splitter
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • ListDEPRECATED
    • Popover
    • QRCode
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • App
    • ConfigProvider
    • Util
ExamplesBasicTypeAutoset Font SizeWith BadgeAvatar.GroupResponsive SizeAPIAvatarAvatar.GroupDesign TokenAvatarUsed to represent users or things, supporting the display of images, icons, or characters.
Importimport { Avatar } from 'antd';
GitHubcomponents/avatarIssueOpen issues
DocsEdit this page
contributorsUploadBadgeloading

Examples

API

Common props ref:Common props

Avatar

PropertyDescriptionTypeDefaultVersion
altThis attribute defines the alternative text describing the imagestring-
gapLetter type unit distance between left and right sidesnumber44.3.0
iconCustom icon type for an icon avatarReactNode-
shapeThe shape of avatarcircle | squarecircle
sizeThe size of the avatarnumber | large | small | default | { xs: number, sm: number, ...}default4.7.0
srcThe address of the image for an image avatar or image elementstring | ReactNode-ReactNode: 4.8.0
srcSetA list of sources to use for different screen resolutionsstring-
draggableWhether the picture is allowed to be draggedboolean | 'true' | 'false'true
crossOriginCORS settings attributes'anonymous' | 'use-credentials' | ''-4.17.0
onErrorHandler when img load error, return false to prevent default fallback behavior() => boolean-

Tip: You can set icon or children as the fallback for image load error, with the priority of icon > children

Avatar.Group 4.5.0+

PropertyDescriptionTypeDefaultVersion
maxSet maximum display related configurations, Before 5.18.0 you can use parameters{ count?: number; style?: CSSProperties; popover?: PopoverProps }-5.18.0
sizeThe size of the avatarnumber | large | small | default | { xs: number, sm: number, ...}default4.8.0
shapeThe shape of the avatarcircle | squarecircle5.8.0

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
containerSizeSize of Avatarnumber32
containerSizeLGSize of large Avatarnumber40
containerSizeSMSize of small Avatarnumber24
groupBorderColorBorder color of avatars in a groupstring#ffffff
groupOverlappingOverlapping of avatars in a groupnumber-8
groupSpaceSpacing between avatars in a groupnumber4
iconFontSizeFont size of Avatar iconnumber18
iconFontSizeLGFont size of large Avatar iconnumber24
iconFontSizeSMFont size of small Avatar iconnumber14
textFontSizeFont size of Avatarnumber14
textFontSizeLGFont size of large Avatarnumber14
textFontSizeSMFont size of small Avatarnumber14
Global TokenHow to use?Basic

Three sizes and two shapes are available.

CodeSandbox IconHitu Iconcodepen iconExternal Link IconExpand IconAutoset Font Size

For letter type Avatar, when the letters are too long to display, the font size can be automatically adjusted according to the width of the Avatar. You can also use gap to set the unit distance between left and right sides.

CodeSandbox IconHitu Iconcodepen iconExternal Link IconExpand IconAvatar.Group

Avatar group display.

CodeSandbox IconHitu Iconcodepen iconExternal Link IconExpand IconType

Image, Icon and letter are supported, and the latter two kinds of avatar can have custom colors and background colors.

CodeSandbox IconHitu Iconcodepen iconExternal Link IconExpand IconWith Badge

Usually used for reminders and notifications.

CodeSandbox IconHitu Iconcodepen iconExternal Link IconExpand IconResponsive Size

Avatar size can be automatically adjusted based on the screen size.

CodeSandbox IconHitu Iconcodepen iconExternal Link IconExpand IconUChangeUserchangeGapKK+2K+2K+2AKUUSERavatarU1

Tag » What Is An Avatar Icon