1
1
---
2
2
title : React Avatar Component
3
3
name : Avatar
4
- description : React avatar component can be used to display circular user profile pictures. Avatar can be used to portray people or objects. It supports images, icons, or letters.
4
+ description : The React Avatar component is used to display circular user profile pictures. React avatars can portray people or objects and support images, icons, or letters.
5
5
menu : Components
6
6
route : /components/avatar
7
7
other_frameworks : avatar
@@ -15,6 +15,8 @@ import Avatar3 from './../assets/images/avatars/3.jpg'
15
15
16
16
## Image avatars
17
17
18
+ Showcase React avatars using images. These avatars are typically circular and can display user profile pictures.
19
+
18
20
``` jsx preview
19
21
< CAvatar src= {Avatar1} / >
20
22
< CAvatar src= {Avatar2} / >
@@ -23,12 +25,36 @@ import Avatar3 from './../assets/images/avatars/3.jpg'
23
25
24
26
## Letter avatars
25
27
28
+ Use letters inside avatars to represent users or objects when images are not available. This can be useful for displaying initials.
29
+
26
30
``` jsx preview
27
31
< CAvatar color= " primary" textColor= " white" > CUI < / CAvatar>
28
32
< CAvatar color= " secondary" > CUI < / CAvatar>
29
33
< CAvatar color= " warning" textColor= " white" > CUI < / CAvatar>
30
34
```
31
35
36
+ ## Icons avatars
37
+
38
+ Incorporate icons within React avatars, allowing for a visual representation using scalable vector graphics (SVG).
39
+
40
+ ``` jsx preview
41
+ < CAvatar color= " info" textColor= " white" >
42
+ < svg id= " cib-coreui-c" className= " icon" viewBox= " 0 0 32 32" >
43
+ <path d="M27.912 7.289l-10.324-5.961c-0.455-0.268-1.002-0.425-1.588-0.425s-1.133 0.158-1.604 0.433l0.015-0.008-10.324 5.961c-0.955 0.561-1.586 1.582-1.588 2.75v11.922c0.002 1.168 0.635 2.189 1.574 2.742l0.016 0.008 10.322 5.961c0.455 0.267 1.004 0.425 1.59 0.425 0.584 0 1.131-0.158 1.602-0.433l-0.014 0.008 10.322-5.961c0.955-0.561 1.586-1.582 1.588-2.75v-11.922c-0.002-1.168-0.633-2.189-1.573-2.742zM27.383 21.961c0 0.389-0.211 0.73-0.526 0.914l-0.004 0.002-10.324 5.961c-0.152 0.088-0.334 0.142-0.53 0.142s-0.377-0.053-0.535-0.145l0.005 0.002-10.324-5.961c-0.319-0.186-0.529-0.527-0.529-0.916v-11.922c0-0.389 0.211-0.73 0.526-0.914l0.004-0.002 10.324-5.961c0.152-0.090 0.334-0.143 0.53-0.143s0.377 0.053 0.535 0.144l-0.006-0.002 10.324 5.961c0.319 0.185 0.529 0.527 0.529 0.916z"></path><path d="M22.094 19.451h-0.758c-0.188 0-0.363 0.049-0.515 0.135l0.006-0.004-4.574 2.512-5.282-3.049v-6.082l5.282-3.051 4.576 2.504c0.146 0.082 0.323 0.131 0.508 0.131h0.758c0.293 0 0.529-0.239 0.529-0.531v-0.716c0-0.2-0.11-0.373-0.271-0.463l-0.004-0.002-5.078-2.777c-0.293-0.164-0.645-0.26-1.015-0.26-0.39 0-0.756 0.106-1.070 0.289l0.010-0.006-5.281 3.049c-0.636 0.375-1.056 1.055-1.059 1.834v6.082c0 0.779 0.422 1.461 1.049 1.828l0.009 0.006 5.281 3.049c0.305 0.178 0.67 0.284 1.061 0.284 0.373 0 0.723-0.098 1.027-0.265l-0.012 0.006 5.080-2.787c0.166-0.091 0.276-0.265 0.276-0.465v-0.716c0-0.293-0.238-0.529-0.529-0.529z"></path>
44
+ < / svg>
45
+ < / CAvatar>
46
+ < CAvatar color= " success" textColor= " white" >
47
+ < svg id= " cib-coreui-c" className= " icon" viewBox= " 0 0 32 32" >
48
+ <path d="M27.912 7.289l-10.324-5.961c-0.455-0.268-1.002-0.425-1.588-0.425s-1.133 0.158-1.604 0.433l0.015-0.008-10.324 5.961c-0.955 0.561-1.586 1.582-1.588 2.75v11.922c0.002 1.168 0.635 2.189 1.574 2.742l0.016 0.008 10.322 5.961c0.455 0.267 1.004 0.425 1.59 0.425 0.584 0 1.131-0.158 1.602-0.433l-0.014 0.008 10.322-5.961c0.955-0.561 1.586-1.582 1.588-2.75v-11.922c-0.002-1.168-0.633-2.189-1.573-2.742zM27.383 21.961c0 0.389-0.211 0.73-0.526 0.914l-0.004 0.002-10.324 5.961c-0.152 0.088-0.334 0.142-0.53 0.142s-0.377-0.053-0.535-0.145l0.005 0.002-10.324-5.961c-0.319-0.186-0.529-0.527-0.529-0.916v-11.922c0-0.389 0.211-0.73 0.526-0.914l0.004-0.002 10.324-5.961c0.152-0.090 0.334-0.143 0.53-0.143s0.377 0.053 0.535 0.144l-0.006-0.002 10.324 5.961c0.319 0.185 0.529 0.527 0.529 0.916z"></path><path d="M22.094 19.451h-0.758c-0.188 0-0.363 0.049-0.515 0.135l0.006-0.004-4.574 2.512-5.282-3.049v-6.082l5.282-3.051 4.576 2.504c0.146 0.082 0.323 0.131 0.508 0.131h0.758c0.293 0 0.529-0.239 0.529-0.531v-0.716c0-0.2-0.11-0.373-0.271-0.463l-0.004-0.002-5.078-2.777c-0.293-0.164-0.645-0.26-1.015-0.26-0.39 0-0.756 0.106-1.070 0.289l0.010-0.006-5.281 3.049c-0.636 0.375-1.056 1.055-1.059 1.834v6.082c0 0.779 0.422 1.461 1.049 1.828l0.009 0.006 5.281 3.049c0.305 0.178 0.67 0.284 1.061 0.284 0.373 0 0.723-0.098 1.027-0.265l-0.012 0.006 5.080-2.787c0.166-0.091 0.276-0.265 0.276-0.465v-0.716c0-0.293-0.238-0.529-0.529-0.529z"></path>
49
+ < / svg>
50
+ < / CAvatar>
51
+ < CAvatar color= " danger" textColor= " white" >
52
+ < svg id= " cib-coreui-c" className= " icon" viewBox= " 0 0 32 32" >
53
+ <path d="M27.912 7.289l-10.324-5.961c-0.455-0.268-1.002-0.425-1.588-0.425s-1.133 0.158-1.604 0.433l0.015-0.008-10.324 5.961c-0.955 0.561-1.586 1.582-1.588 2.75v11.922c0.002 1.168 0.635 2.189 1.574 2.742l0.016 0.008 10.322 5.961c0.455 0.267 1.004 0.425 1.59 0.425 0.584 0 1.131-0.158 1.602-0.433l-0.014 0.008 10.322-5.961c0.955-0.561 1.586-1.582 1.588-2.75v-11.922c-0.002-1.168-0.633-2.189-1.573-2.742zM27.383 21.961c0 0.389-0.211 0.73-0.526 0.914l-0.004 0.002-10.324 5.961c-0.152 0.088-0.334 0.142-0.53 0.142s-0.377-0.053-0.535-0.145l0.005 0.002-10.324-5.961c-0.319-0.186-0.529-0.527-0.529-0.916v-11.922c0-0.389 0.211-0.73 0.526-0.914l0.004-0.002 10.324-5.961c0.152-0.090 0.334-0.143 0.53-0.143s0.377 0.053 0.535 0.144l-0.006-0.002 10.324 5.961c0.319 0.185 0.529 0.527 0.529 0.916z"></path><path d="M22.094 19.451h-0.758c-0.188 0-0.363 0.049-0.515 0.135l0.006-0.004-4.574 2.512-5.282-3.049v-6.082l5.282-3.051 4.576 2.504c0.146 0.082 0.323 0.131 0.508 0.131h0.758c0.293 0 0.529-0.239 0.529-0.531v-0.716c0-0.2-0.11-0.373-0.271-0.463l-0.004-0.002-5.078-2.777c-0.293-0.164-0.645-0.26-1.015-0.26-0.39 0-0.756 0.106-1.070 0.289l0.010-0.006-5.281 3.049c-0.636 0.375-1.056 1.055-1.059 1.834v6.082c0 0.779 0.422 1.461 1.049 1.828l0.009 0.006 5.281 3.049c0.305 0.178 0.67 0.284 1.061 0.284 0.373 0 0.723-0.098 1.027-0.265l-0.012 0.006 5.080-2.787c0.166-0.091 0.276-0.265 0.276-0.465v-0.716c0-0.293-0.238-0.529-0.529-0.529z"></path>
54
+ < / svg>
55
+ < / CAvatar>
56
+ ```
57
+
32
58
## Rounded avatars
33
59
34
60
Use the ` shape="rounded" ` prop to make react avatars squared with rounded corners.
@@ -51,25 +77,49 @@ Use the `shape="rounded-0"` prop to make react avatars squared.
51
77
52
78
## Sizes
53
79
54
- Fancy larger or smaller react avatar component? Add ` size="xl" ` , ` size="lg" ` or ` size="sm" ` for additional sizes.
80
+ Fancy larger or smaller react avatar component? Add ` size="xl" ` , ` size="lg" ` , ` size="md" ` or ` size="sm" ` for additional sizes.
55
81
56
82
``` jsx preview
57
83
< CAvatar color= " secondary" size= " xl" > CUI < / CAvatar>
58
84
< CAvatar color= " secondary" size= " lg" > CUI < / CAvatar>
85
+ < CAvatar color= " secondary" size= " md" > CUI < / CAvatar>
59
86
< CAvatar color= " secondary" > CUI < / CAvatar>
60
87
< CAvatar color= " secondary" size= " sm" > CUI < / CAvatar>
61
88
```
62
89
63
90
## Avatars with status
64
91
92
+ Add a status indicator to avatars using the ` status ` property to show online or offline status.
93
+
65
94
``` jsx preview
66
95
< CAvatar src= {Avatar1} status= " success" / >
67
96
< CAvatar color= " secondary" status= " danger" > CUI < / CAvatar>
68
97
```
69
98
99
+ ## Customizing
100
+
101
+ ### CSS variables
102
+
103
+ React avatars use local CSS variables on ` .avatar ` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
104
+
105
+ <ScssDocs file = " _avatar.scss" capture = " avatar-css-vars" />
106
+
107
+ #### How to use CSS variables
108
+
109
+ ``` jsx
110
+ const vars = {
111
+ ' --my-css-var' : 10 ,
112
+ ' --my-another-css-var' : ' red' ,
113
+ }
114
+ return < CAvatar style= {vars}> ... < / CAvatar>
115
+ ```
116
+
117
+ ### SASS variables
118
+
119
+ <ScssDocs file = " _variables.scss" capture = " avatar-variables" />
120
+
70
121
## API
71
122
72
123
### CAvatar
73
124
74
125
` markdown:CAvatar.api.mdx `
75
-
0 commit comments