| 1 |
--- |
| 2 |
id: Avatar |
| 3 |
section: components |
| 4 |
cssPrefix: pf-v6-c-avatar |
| 5 |
propComponents: ['Avatar'] |
| 6 |
--- |
| 7 |
|
| 8 |
import './avatar.css'; |
| 9 |
import { Fragment } from 'react'; |
| 10 |
import avatarImg from '../../assets/img_avatar-light.svg'; |
| 11 |
import RhUiAiChatbotIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ai-chatbot-icon'; |
| 12 |
|
| 13 |
## Examples |
| 14 |
|
| 15 |
### Basic usage |
| 16 |
|
| 17 |
Pass in the `src` property to apply an image for the avatar, or pass `children` for custom content such as icons or svg elements. |
| 18 |
|
| 19 |
```ts file="./AvatarBasic.tsx" |
| 20 |
|
| 21 |
``` |
| 22 |
|
| 23 |
### Color modifiers |
| 24 |
|
| 25 |
Color modifiers add visual interest and automatically include a border. The available colors are: "red," "orangered," "orange," "yellow," "green," "teal," "blue," "purple," and "gray". |
| 26 |
|
| 27 |
```ts file="./AvatarColorModifiers.tsx" |
| 28 |
|
| 29 |
``` |
| 30 |
|
| 31 |
### With initials |
| 32 |
|
| 33 |
An avatar can display initials by using the `initials` property. It's recommended to pass only a single initial to ensure the text fits inside of the avatar. |
| 34 |
|
| 35 |
```ts file="./AvatarInitials.tsx" |
| 36 |
|
| 37 |
``` |
| 38 |
|
| 39 |
### Bordered |
| 40 |
|
| 41 |
A border can be applied by passing the `isBordered` property to a non-colorful avatar. |
| 42 |
|
| 43 |
```ts file="./AvatarBordered.tsx" |
| 44 |
|
| 45 |
``` |
| 46 |
|
| 47 |
### Size variations |
| 48 |
|
| 49 |
An avatar can be rendered at different sizes by passing the `size` property. The available sizes are: "sm," "md" (the default size), "lg," and "xl". |
| 50 |
|
| 51 |
```ts file="./AvatarSizeVariations.tsx" |
| 52 |
|
| 53 |
``` |