@instructure/ui-avatar 11.6.0 → 11.6.1-snapshot-129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +39 -294
  2. package/es/Avatar/{index.js → v1/index.js} +2 -2
  3. package/es/Avatar/v2/index.js +168 -0
  4. package/es/Avatar/v2/props.js +35 -0
  5. package/es/Avatar/v2/styles.js +166 -0
  6. package/es/{index.js → exports/a.js} +1 -1
  7. package/{src/index.ts → es/exports/b.js} +1 -2
  8. package/lib/Avatar/{index.js → v1/index.js} +3 -3
  9. package/lib/Avatar/v2/index.js +174 -0
  10. package/lib/Avatar/v2/props.js +40 -0
  11. package/lib/Avatar/v2/styles.js +172 -0
  12. package/lib/{index.js → exports/a.js} +2 -2
  13. package/lib/exports/b.js +12 -0
  14. package/package.json +39 -17
  15. package/src/Avatar/{index.tsx → v1/index.tsx} +2 -2
  16. package/src/Avatar/v2/README.md +277 -0
  17. package/src/Avatar/v2/index.tsx +175 -0
  18. package/src/Avatar/v2/props.ts +137 -0
  19. package/src/Avatar/v2/styles.ts +194 -0
  20. package/src/exports/a.ts +25 -0
  21. package/src/exports/b.ts +25 -0
  22. package/tsconfig.build.tsbuildinfo +1 -1
  23. package/types/Avatar/{index.d.ts → v1/index.d.ts} +1 -1
  24. package/types/Avatar/v1/index.d.ts.map +1 -0
  25. package/types/Avatar/v1/props.d.ts.map +1 -0
  26. package/types/Avatar/v1/styles.d.ts.map +1 -0
  27. package/types/Avatar/v1/theme.d.ts.map +1 -0
  28. package/types/Avatar/v2/index.d.ts +60 -0
  29. package/types/Avatar/v2/index.d.ts.map +1 -0
  30. package/types/Avatar/v2/props.d.ts +76 -0
  31. package/types/Avatar/v2/props.d.ts.map +1 -0
  32. package/types/Avatar/v2/styles.d.ts +26 -0
  33. package/types/Avatar/v2/styles.d.ts.map +1 -0
  34. package/types/exports/a.d.ts +3 -0
  35. package/types/exports/a.d.ts.map +1 -0
  36. package/types/exports/b.d.ts +3 -0
  37. package/types/exports/b.d.ts.map +1 -0
  38. package/types/Avatar/index.d.ts.map +0 -1
  39. package/types/Avatar/props.d.ts.map +0 -1
  40. package/types/Avatar/styles.d.ts.map +0 -1
  41. package/types/Avatar/theme.d.ts.map +0 -1
  42. package/types/index.d.ts +0 -3
  43. package/types/index.d.ts.map +0 -1
  44. /package/es/Avatar/{props.js → v1/props.js} +0 -0
  45. /package/es/Avatar/{styles.js → v1/styles.js} +0 -0
  46. /package/es/Avatar/{theme.js → v1/theme.js} +0 -0
  47. /package/lib/Avatar/{props.js → v1/props.js} +0 -0
  48. /package/lib/Avatar/{styles.js → v1/styles.js} +0 -0
  49. /package/lib/Avatar/{theme.js → v1/theme.js} +0 -0
  50. /package/src/Avatar/{README.md → v1/README.md} +0 -0
  51. /package/src/Avatar/{props.ts → v1/props.ts} +0 -0
  52. /package/src/Avatar/{styles.ts → v1/styles.ts} +0 -0
  53. /package/src/Avatar/{theme.ts → v1/theme.ts} +0 -0
  54. /package/types/Avatar/{props.d.ts → v1/props.d.ts} +0 -0
  55. /package/types/Avatar/{styles.d.ts → v1/styles.d.ts} +0 -0
  56. /package/types/Avatar/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _emotion = require("@instructure/emotion");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param componentTheme The theme variable object.
38
+ * @param params Additional parameters to customize the style.
39
+ * @param sharedTokens Shared token object that stores common values for the theme.
40
+ * @return The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = (componentTheme, params, sharedTokens) => {
43
+ const loaded = params.loaded,
44
+ size = params.size,
45
+ color = params.color,
46
+ hasInverseColor = params.hasInverseColor,
47
+ shape = params.shape,
48
+ showBorder = params.showBorder,
49
+ display = params.display,
50
+ margin = params.margin;
51
+ const sizeStyles = {
52
+ 'xx-small': {
53
+ fontSize: componentTheme.fontSize2xs,
54
+ borderWidth: componentTheme.borderWidthSm,
55
+ width: componentTheme.size2xs,
56
+ height: componentTheme.size2xs
57
+ },
58
+ 'x-small': {
59
+ fontSize: componentTheme.fontSizeXs,
60
+ borderWidth: componentTheme.borderWidthSm,
61
+ width: componentTheme.sizeXs,
62
+ height: componentTheme.sizeXs
63
+ },
64
+ small: {
65
+ fontSize: componentTheme.fontSizeSm,
66
+ borderWidth: componentTheme.borderWidthSm,
67
+ width: componentTheme.sizeSm,
68
+ height: componentTheme.sizeSm
69
+ },
70
+ medium: {
71
+ fontSize: componentTheme.fontSizeMd,
72
+ borderWidth: componentTheme.borderWidthMd,
73
+ width: componentTheme.sizeMd,
74
+ height: componentTheme.sizeMd
75
+ },
76
+ large: {
77
+ fontSize: componentTheme.fontSizeLg,
78
+ borderWidth: componentTheme.borderWidthMd,
79
+ width: componentTheme.sizeLg,
80
+ height: componentTheme.sizeLg
81
+ },
82
+ 'x-large': {
83
+ fontSize: componentTheme.fontSizeXl,
84
+ borderWidth: componentTheme.borderWidthMd,
85
+ width: componentTheme.sizeXl,
86
+ height: componentTheme.sizeXl
87
+ },
88
+ 'xx-large': {
89
+ fontSize: componentTheme.fontSize2xl,
90
+ borderWidth: componentTheme.borderWidthMd,
91
+ width: componentTheme.size2xl,
92
+ height: componentTheme.size2xl
93
+ }
94
+ };
95
+ const colorVariants = {
96
+ accent1: {
97
+ text: componentTheme.blueTextColor,
98
+ background: componentTheme.blueBackgroundColor
99
+ },
100
+ accent2: {
101
+ text: componentTheme.greenTextColor,
102
+ background: componentTheme.greenBackgroundColor
103
+ },
104
+ accent3: {
105
+ text: componentTheme.redTextColor,
106
+ background: componentTheme.redBackgroundColor
107
+ },
108
+ accent4: {
109
+ text: componentTheme.orangeTextColor,
110
+ background: componentTheme.orangeBackgroundColor
111
+ },
112
+ accent5: {
113
+ text: componentTheme.greyTextColor,
114
+ background: componentTheme.greyBackgroundColor
115
+ },
116
+ accent6: {
117
+ text: componentTheme.ashTextColor,
118
+ background: componentTheme.ashBackgroundColor
119
+ },
120
+ ai: {
121
+ text: componentTheme.textOnColor,
122
+ background: `linear-gradient(135deg, ${componentTheme.aiTopGradientColor} 0%, ${componentTheme.aiBottomGradientColor} 100%)`
123
+ }
124
+ };
125
+ const getBorder = () => {
126
+ if (showBorder === 'never') {
127
+ return 'none';
128
+ }
129
+ if (showBorder === 'always') {
130
+ return 'solid';
131
+ }
132
+ //if none of the above, so auto
133
+ if (hasInverseColor || color === 'ai') {
134
+ return 'none';
135
+ }
136
+ return 'solid';
137
+ };
138
+ return {
139
+ avatar: {
140
+ label: 'avatar',
141
+ boxSizing: 'border-box',
142
+ border: getBorder(),
143
+ borderRadius: shape === 'circle' ? '50%' : 0,
144
+ ...sizeStyles[size],
145
+ background: hasInverseColor || color === 'ai' ? colorVariants[color].background : componentTheme.backgroundColor,
146
+ display: display === 'inline' ? 'inline-flex' : 'flex',
147
+ alignItems: 'center',
148
+ justifyContent: 'center',
149
+ verticalAlign: 'middle',
150
+ color: hasInverseColor ? componentTheme.textOnColor : colorVariants[color].text,
151
+ borderColor: componentTheme.borderColor,
152
+ fontWeight: componentTheme.fontWeight,
153
+ overflow: 'hidden',
154
+ // TODO handle the merging on tokens inside the util
155
+ margin: (0, _emotion.calcSpacingFromShorthand)(margin, {
156
+ ...sharedTokens.spacing,
157
+ ...sharedTokens.legacy.spacing
158
+ })
159
+ },
160
+ image: {
161
+ label: 'avatar__image',
162
+ width: '100%',
163
+ height: '100%',
164
+ objectFit: 'cover',
165
+ objectPosition: 'center',
166
+ ...(loaded ? {} : {
167
+ display: 'none'
168
+ })
169
+ }
170
+ };
171
+ };
172
+ var _default = exports.default = generateStyle;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "Avatar", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _Avatar.Avatar;
9
+ return _v.Avatar;
10
10
  }
11
11
  });
12
- var _Avatar = require("./Avatar");
12
+ var _v = require("../Avatar/v1");
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Avatar", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _v.Avatar;
10
+ }
11
+ });
12
+ var _v = require("../Avatar/v2");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-avatar",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-snapshot-129",
4
4
  "description": "An image or letters that represents a user.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -15,20 +15,20 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/ui-icons": "11.6.0",
19
- "@instructure/emotion": "11.6.0",
20
- "@instructure/shared-types": "11.6.0",
21
- "@instructure/ui-react-utils": "11.6.0",
22
- "@instructure/ui-view": "11.6.0"
18
+ "@instructure/emotion": "11.6.1-snapshot-129",
19
+ "@instructure/ui-icons": "11.6.1-snapshot-129",
20
+ "@instructure/ui-view": "11.6.1-snapshot-129",
21
+ "@instructure/shared-types": "11.6.1-snapshot-129",
22
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@testing-library/jest-dom": "^6.6.3",
26
26
  "@testing-library/react": "15.0.7",
27
27
  "vitest": "^3.2.2",
28
- "@instructure/ui-axe-check": "11.6.0",
29
- "@instructure/ui-babel-preset": "11.6.0",
30
- "@instructure/ui-themes": "11.6.0",
31
- "@instructure/ui-color-utils": "11.6.0"
28
+ "@instructure/ui-axe-check": "11.6.1-snapshot-129",
29
+ "@instructure/ui-babel-preset": "11.6.1-snapshot-129",
30
+ "@instructure/ui-color-utils": "11.6.1-snapshot-129",
31
+ "@instructure/ui-themes": "11.6.1-snapshot-129"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=18 <=19"
@@ -38,17 +38,39 @@
38
38
  },
39
39
  "sideEffects": false,
40
40
  "exports": {
41
- ".": {
42
- "types": "./types/index.d.ts",
43
- "import": "./es/index.js",
44
- "require": "./lib/index.js",
45
- "default": "./es/index.js"
46
- },
47
41
  "./lib/*": "./lib/*",
48
42
  "./es/*": "./es/*",
49
43
  "./types/*": "./types/*",
50
44
  "./package.json": "./package.json",
51
- "./src/*": "./src/*"
45
+ "./src/*": "./src/*",
46
+ ".": {
47
+ "src": "./src/exports/a.ts",
48
+ "types": "./types/exports/a.d.ts",
49
+ "import": "./es/exports/a.js",
50
+ "require": "./lib/exports/a.js",
51
+ "default": "./es/exports/a.js"
52
+ },
53
+ "./v11_6": {
54
+ "src": "./src/exports/a.ts",
55
+ "types": "./types/exports/a.d.ts",
56
+ "import": "./es/exports/a.js",
57
+ "require": "./lib/exports/a.js",
58
+ "default": "./es/exports/a.js"
59
+ },
60
+ "./v11_7": {
61
+ "src": "./src/exports/b.ts",
62
+ "types": "./types/exports/b.d.ts",
63
+ "import": "./es/exports/b.js",
64
+ "require": "./lib/exports/b.js",
65
+ "default": "./es/exports/b.js"
66
+ },
67
+ "./latest": {
68
+ "src": "./src/exports/b.ts",
69
+ "types": "./types/exports/b.d.ts",
70
+ "import": "./es/exports/b.js",
71
+ "require": "./lib/exports/b.js",
72
+ "default": "./es/exports/b.js"
73
+ }
52
74
  },
53
75
  "scripts": {
54
76
  "lint": "ui-scripts lint",
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import { useStyle } from '@instructure/emotion'
25
+ import { useStyleLegacy as useStyle } from '@instructure/emotion'
26
26
  import {
27
27
  useState,
28
28
  SyntheticEvent,
@@ -32,7 +32,7 @@ import {
32
32
  useRef
33
33
  } from 'react'
34
34
 
35
- import { View } from '@instructure/ui-view'
35
+ import { View } from '@instructure/ui-view/v11_6'
36
36
  import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
37
37
  import type { AvatarProps } from './props'
38
38
 
@@ -0,0 +1,277 @@
1
+ ---
2
+ describes: Avatar
3
+ ---
4
+
5
+ The avatar component can be used to display a user's avatar. When an image src is not supplied the user's initials will display.
6
+
7
+ Instead of the initials, an SVG icon can be displayed with the `renderIcon` property. **Note: If both `src` and `renderIcon` are provided, the image (`src`) takes priority.**
8
+
9
+ The avatar can be `circle` _(default)_ or `rectangle`. The component uses flexbox layout and can be displayed as `inline` _(default)_ or `block` using the `display` prop.
10
+
11
+ ```js
12
+ ---
13
+ type: example
14
+ readonly: true
15
+ ---
16
+
17
+ <div>
18
+ <View display="block" padding="small medium" background="primary">
19
+ <Avatar name="Arthur C. Clarke" />
20
+ <Avatar name="James Arias" color="accent2" />
21
+ <Avatar name="Charles Kimball" color="accent3" />
22
+ <Avatar name="Melissa Reed" color="accent4" />
23
+ <Avatar name="Heather Wheeler" color="accent5" />
24
+ <Avatar name="David Herbert" color="accent6" />
25
+ <Avatar name="Isaac Asimov" color="accent1" />
26
+ </View>
27
+ <View display="block" padding="small medium" background="primary">
28
+ <Avatar name="Arthur C. Clarke" hasInverseColor />
29
+ <Avatar name="James Arias" color="accent2" hasInverseColor />
30
+ <Avatar name="Charles Kimball" color="accent3" hasInverseColor />
31
+ <Avatar name="Melissa Reed" color="accent4" hasInverseColor />
32
+ <Avatar name="Heather Wheeler" color="accent5" hasInverseColor />
33
+ <Avatar name="David Herbert" color="accent6" hasInverseColor />
34
+ <Avatar name="Isaac Asimov" color="accent1" hasInverseColor />
35
+ </View>
36
+ </div>
37
+ ```
38
+
39
+ ### AI Avatar
40
+
41
+ There is a need for special, `ai avatars`. These have a specific look. You can achieve it the following way
42
+
43
+ ```js
44
+ ---
45
+ type: example
46
+ readonly: true
47
+ ---
48
+ <View display="block" padding="small medium" background="primary">
49
+ <Avatar size="xx-small" color="ai" name="AI Assistant" renderIcon={IconAiSolid} />
50
+ <Avatar size="x-small" color="ai" name="AI Assistant" renderIcon={IconAiSolid} />
51
+ <Avatar size="small" color="ai" name="AI Assistant" renderIcon={IconAiSolid} />
52
+ <Avatar size="medium" color="ai" name="AI Assistant" renderIcon={IconAiSolid} />
53
+ <Avatar size="large" color="ai" name="AI Assistant" renderIcon={IconAiSolid} />
54
+ <Avatar size="x-large" color="ai" name="AI Assistant" renderIcon={IconAiSolid} />
55
+ <Avatar size="xx-large" color="ai" name="AI Assistant" renderIcon={IconAiSolid} />
56
+ </View>
57
+ ```
58
+
59
+ ### Using Lucide Icons
60
+
61
+ Lucide icons in Avatar are automatically sized and colored according to the Avatar's `size` and `color` props, so manual adjustments are not needed on the icon itself.
62
+
63
+ ```js
64
+ ---
65
+ type: example
66
+ ---
67
+ <div>
68
+ <View display="block" padding="small medium">
69
+ <Avatar name="User Avatar" size="xx-small" renderIcon={UserInstUIIcon} />
70
+ <Avatar name="User Avatar" size="x-small" renderIcon={UserInstUIIcon} />
71
+ <Avatar name="User Avatar" size="small" renderIcon={UserInstUIIcon} />
72
+ <Avatar name="User Avatar" size="medium" renderIcon={UserInstUIIcon} />
73
+ <Avatar name="User Avatar" size="large" renderIcon={UserInstUIIcon} />
74
+ <Avatar name="User Avatar" size="x-large" renderIcon={UserInstUIIcon} />
75
+ <Avatar name="User Avatar" size="xx-large" renderIcon={UserInstUIIcon} />
76
+ </View>
77
+ <View display="block" padding="small medium">
78
+ <Avatar name="Profile" size="small" color="accent2" renderIcon={<CircleUserInstUIIcon />} />
79
+ <Avatar name="Group" size="medium" color="accent3" renderIcon={<UsersInstUIIcon />} />
80
+ <Avatar name="Settings" size="large" color="accent4" renderIcon={<SettingsInstUIIcon />} />
81
+ </View>
82
+ <View display="block" padding="small medium">
83
+ <Avatar name="Profile" size="large" color="accent4" renderIcon={()=><CircleUserInstUIIcon />} />
84
+ <Avatar name="Group" size="x-large" color="accent5" renderIcon={()=><UsersInstUIIcon />} />
85
+ <Avatar name="Settings" size="xx-large" color="accent6" renderIcon={()=><SettingsInstUIIcon />} />
86
+ </View>
87
+ </div>
88
+ ```
89
+
90
+ ### Size
91
+
92
+ The `size` prop allows you to select from `xx-small`, `x-small`, `small`, `medium` _(default)_, `large`, `x-large`, and `xx-large`. Each size has predefined dimensions and typography scales.
93
+
94
+ ```js
95
+ ---
96
+ type: example
97
+ ---
98
+ <div>
99
+ <View display="block" padding="small medium">
100
+ <Avatar name="Arthur C. Clarke" size="xx-small" />
101
+ <Avatar name="James Arias" size="x-small" />
102
+ <Avatar name="Charles Kimball" size="small" />
103
+ <Avatar name="Melissa Reed" size="medium" />
104
+ <Avatar name="Heather Wheeler" size="large" />
105
+ <Avatar name="David Herbert" size="x-large" />
106
+ <Avatar name="Isaac Asimov" size="xx-large" />
107
+ </View>
108
+ <View display="block" padding="small medium" background="primary">
109
+ <Avatar name="Arthur C. Clarke" size="xx-small" src={avatarSquare} />
110
+ <Avatar name="James Arias" size="x-small" src={avatarSquare} />
111
+ <Avatar name="Charles Kimball" size="small" src={avatarSquare} />
112
+ <Avatar name="Melissa Reed" size="medium" src={avatarSquare} />
113
+ <Avatar name="Heather Wheeler" size="large" src={avatarSquare} />
114
+ <Avatar name="David Herbert" size="x-large" src={avatarSquare} />
115
+ <Avatar name="Isaac Asimov" size="xx-large" src={avatarSquare} />
116
+ </View>
117
+ <View display="block" padding="small medium">
118
+ <Avatar name="Arthur C. Clarke" renderIcon={UsersInstUIIcon} size="xx-small" />
119
+ <Avatar name="James Arias" renderIcon={UsersInstUIIcon} size="x-small" />
120
+ <Avatar name="Charles Kimball" renderIcon={UsersInstUIIcon} size="small" />
121
+ <Avatar name="Melissa Reed" renderIcon={UsersInstUIIcon} size="medium" />
122
+ <Avatar name="Heather Wheeler" renderIcon={UsersInstUIIcon} size="large" />
123
+ <Avatar name="David Herbert" renderIcon={UsersInstUIIcon} size="x-large" />
124
+ <Avatar name="Isaac Asimov" renderIcon={UsersInstUIIcon} size="xx-large" />
125
+ </View>
126
+ </div>
127
+ ```
128
+
129
+ ### Colors
130
+
131
+ The color of the initials and icons can be set with the `color` prop, and it allows you to select from `accent1` _(default)_, `accent2`, `accent3`, `accent4`, `accent5`, `accent6`, and `ai` _(for AI avatars with gradient background)_.
132
+
133
+ ```js
134
+ ---
135
+ type: example
136
+ ---
137
+ <div>
138
+ <View display="block" padding="small medium">
139
+ <Avatar name="Arthur C. Clarke" />
140
+ <Avatar name="James Arias" color="accent2" />
141
+ <Avatar name="Charles Kimball" color="accent3" />
142
+ <Avatar name="Melissa Reed" color="accent4" />
143
+ <Avatar name="Heather Wheeler" color="accent5" />
144
+ <Avatar name="David Herbert" color="accent6" />
145
+ <Avatar name="Isaac Asimov" color="accent1" />
146
+ </View>
147
+ <View display="block" padding="small medium">
148
+ <Avatar renderIcon={UsersInstUIIcon} name="Arthur C. Clarke" />
149
+ <Avatar renderIcon={UsersInstUIIcon} name="James Arias" color="accent2" />
150
+ <Avatar renderIcon={UsersInstUIIcon} name="Charles Kimball" color="accent3" />
151
+ <Avatar renderIcon={UsersInstUIIcon} name="Melissa Reed" color="accent4" />
152
+ <Avatar renderIcon={UsersInstUIIcon} name="Heather Wheeler" color="accent5" />
153
+ <Avatar renderIcon={UsersInstUIIcon} name="David Herbert" color="accent6" />
154
+ <Avatar renderIcon={UsersInstUIIcon} name="Isaac Asimov" color="accent1" />
155
+ </View>
156
+ </div>
157
+ ```
158
+
159
+ The `hasInverseColor` prop inverts the background color and the text/icon color.
160
+
161
+ Inverted Avatars have **no border**.
162
+
163
+ ```js
164
+ ---
165
+ type: example
166
+ ---
167
+ <div>
168
+ <View display="block" padding="small medium" background="primary">
169
+ <Avatar name="Arthur C. Clarke" hasInverseColor />
170
+ <Avatar name="James Arias" color="accent2" hasInverseColor />
171
+ <Avatar name="Charles Kimball" color="accent3" hasInverseColor />
172
+ <Avatar name="Melissa Reed" color="accent4" hasInverseColor />
173
+ <Avatar name="Heather Wheeler" color="accent5" hasInverseColor />
174
+ <Avatar name="David Herbert" color="accent6" hasInverseColor />
175
+ <Avatar name="Isaac Asimov" color="accent1" hasInverseColor />
176
+ </View>
177
+ <View display="block" padding="small medium" background="primary">
178
+ <Avatar renderIcon={UsersInstUIIcon} name="Arthur C. Clarke" hasInverseColor />
179
+ <Avatar renderIcon={UsersInstUIIcon} name="James Arias" color="accent2" hasInverseColor />
180
+ <Avatar renderIcon={UsersInstUIIcon} name="Charles Kimball" color="accent3" hasInverseColor />
181
+ <Avatar renderIcon={UsersInstUIIcon} name="Melissa Reed" color="accent4" hasInverseColor />
182
+ <Avatar renderIcon={UsersInstUIIcon} name="Heather Wheeler" color="accent5" hasInverseColor />
183
+ <Avatar renderIcon={UsersInstUIIcon} name="David Herbert" color="accent6" hasInverseColor />
184
+ <Avatar renderIcon={UsersInstUIIcon} name="Isaac Asimov" color="accent1" hasInverseColor />
185
+ </View>
186
+ </div>
187
+ ```
188
+
189
+ In case you need more control over the color, feel free to use the `themeOverride` prop, and override the default theme variables.
190
+
191
+ ```js
192
+ ---
193
+ type: example
194
+ ---
195
+ <div>
196
+ <Avatar name="Isaac Asimov" renderIcon={UsersInstUIIcon} themeOverride={{ accent1TextColor: '#efb410' }} />
197
+ <Avatar name="Heather Wheeler" color="accent5" themeOverride={{ accent5TextColor: 'magenta' }} />
198
+ <Avatar name="Charles Kimball" renderIcon={UsersInstUIIcon} hasInverseColor themeOverride={{ textOnColor: 'lightblue', backgroundColor: 'black' }} />
199
+ <Avatar name="David Herbert" hasInverseColor color="accent5" themeOverride={{ accent5BackgroundColor: '#efb410' }} />
200
+ </div>
201
+ ```
202
+
203
+ ### Display
204
+
205
+ The `display` prop controls whether the avatar is displayed as `inline` _(default)_ or `block`. This affects the CSS display property and layout behavior.
206
+
207
+ ```js
208
+ ---
209
+ type: example
210
+ ---
211
+ <div>
212
+ <Text>Inline avatars: </Text>
213
+ <Avatar name="John Doe" size="small" display="inline" />
214
+ <Avatar name="Jane Smith" size="small" display="inline" />
215
+ <Text> are displayed inline with text.</Text>
216
+
217
+ <div style={{ marginTop: '1rem' }}>
218
+ <Text>Block avatars:</Text>
219
+ <Avatar name="John Doe" size="small" display="block" />
220
+ <Avatar name="Jane Smith" size="small" display="block" />
221
+ <Text>stack vertically.</Text>
222
+ </div>
223
+ </div>
224
+ ```
225
+
226
+ ### Border
227
+
228
+ By default only avatars without an image have borders but you can force it to `always` or `never` show with the `showBorder` prop however you should only use it rarely in very specific occasions (e.g. displaying an avatar in the [SideNavBar](/#SideNavBar))
229
+
230
+ ```js
231
+ ---
232
+ type: example
233
+ ---
234
+ <div>
235
+ <Avatar name="Sarah Robinson" src={avatarSquare} showBorder="always" />
236
+ <Avatar name="Sarah Robinson" renderIcon={UsersInstUIIcon} showBorder="never" />
237
+ </div>
238
+ ```
239
+
240
+ ### Priority and Behavior
241
+
242
+ When both `src` and `renderIcon` props are provided, the **image (`src`) takes priority** and will be displayed instead of the icon. The icon will only be shown as a fallback while the image is loading or if the image fails to load.
243
+
244
+ ```js
245
+ ---
246
+ type: example
247
+ ---
248
+ <div>
249
+ <Avatar
250
+ name="John Doe"
251
+ src={avatarSquare}
252
+ renderIcon={UsersInstUIIcon}
253
+ />
254
+ <Text>Image takes priority over icon</Text>
255
+ </div>
256
+ ```
257
+
258
+ ### Accessibility
259
+
260
+ Avatars use the `aria-hidden="true"` property and therefore are hidden from screenreaders. Make sure if you are using them stand-alone it's accompanied with [ScreenReaderContent](ScreenReaderContent).
261
+
262
+ ### Guidelines
263
+
264
+ ```js
265
+ ---
266
+ type: embed
267
+ ---
268
+ <Guidelines>
269
+ <Figure recommendation="yes" title="Do">
270
+ <Figure.Item>Ensure the appropriate size is being used for its placement (in a table, stand-alone, etc…)</Figure.Item>
271
+ <Figure.Item>Use circle variant in Canvas</Figure.Item>
272
+ </Figure>
273
+ <Figure recommendation="no" title="Don't">
274
+ <Figure.Item>Use inline in sentence</Figure.Item>
275
+ </Figure>
276
+ </Guidelines>
277
+ ```