2017-05-28 14:20:59 +08:00
|
|
|
---
|
|
|
|
category: Components
|
|
|
|
type: Data Display
|
|
|
|
title: Avatar
|
2020-05-31 11:48:34 +08:00
|
|
|
cover: https://gw.alipayobjects.com/zos/antfincdn/aBcnbw68hP/Avatar.svg
|
2017-05-28 14:20:59 +08:00
|
|
|
---
|
|
|
|
|
2017-09-16 11:29:51 +08:00
|
|
|
Avatars can be used to represent people or objects. It supports images, `Icon`s, or letters.
|
2017-05-28 14:20:59 +08:00
|
|
|
|
|
|
|
## API
|
|
|
|
|
2019-07-11 14:14:33 +08:00
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
| --- | --- | --- | --- | --- |
|
2019-08-13 14:07:17 +08:00
|
|
|
| icon | custom icon type for an icon avatar | ReactNode | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
| shape | the shape of avatar | `circle` \| `square` | `circle` | |
|
2020-01-17 17:23:48 +08:00
|
|
|
| size | the size of the avatar | number \| `large` \| `small` \| `default` | `default` | |
|
2019-07-11 14:14:33 +08:00
|
|
|
| src | the address of the image for an image avatar | string | - | |
|
2019-11-20 20:31:43 +08:00
|
|
|
| srcSet | a list of sources to use for different screen resolutions | string | - | |
|
|
|
|
| alt | This attribute defines the alternative text describing the image | string | - | |
|
|
|
|
| onError | handler when img load error, return false to prevent default fallback behavior | () => boolean | - | |
|
2020-05-25 17:56:48 +08:00
|
|
|
| gap | Letter type unit distance between left and right sides | number | 4 | 4.3.0 |
|
2020-06-12 15:26:40 +08:00
|
|
|
|
|
|
|
> Tip: You can set `icon` or `children` as the fallback for image load error, with the priority of `icon` > `children`
|