Developer-friendly React component to display responsive user avatars. Avatar images are powered by UI Avatars. Some wilder variations can be seen here.
npm install react-avatar-group
import React from 'react';
import AvatarGroup from 'react-avatar-group';
function App() {
return (
<AvatarGroup
avatars={["James", "Amy", "Will" /* or IAvatar objects */]}
initialCharacters={1}
max={3}
size={60}
displayAllOnHover
shadow={2}
/>
)
}
Array of strings with avatar names or Avatar object for more control
Click handler for individual avatars
Limit the number of avatars that can be shown at once. If the avatar array length is greater than this number, an overflow avatar will be shown detailing how many avatars are hidden.
If max
is provided and displayAllOnHover is true, even the overflowing avatars will be shown when the mouse hovers over the group element
Should the avatars be square instead of rounded
Avatar image size in pixels. Between: 16 and 512
Array of Hex colors to choose from as background colors, without the hash (#). This will be overridden by backgroundColor
Box-shadow elevation as an integer from 1 to 5
Styles applied to all individual avatar components
Don't display a tooltip when the mouse hovers over an individual avatar
Font size in percentage of size. Between 0.1 and 1
Decide if the API should uppercase the name/initials
Boolean specifying if the returned letters should use a bold font
Length of the generated initials
Hex color for the image background, without the hash (#). Overrides randomBackgroundColors
Hex color for the font, without the hash (#)
Styles applied to all tooltips
Display a small arrow on the tooltip
This is an object that can be passed in the avatars
array (instead of a string) for more control over individual avatars. All of these props will override the corresponding ones above.
The required avatar string
Custom text to put in the tooltip, rather than the avatar
string
- Allow for custom image urls
- Codepen example
- Avoid global tooltip css