--- title: Avatars path: components/avatars status: Stable source: 'https://github.com/primer/css/tree/master/src/avatars' bundle: avatars --- Avatars are images that users can set as their profile picture. On GitHub, they're always going to be rounded squares. They can be custom photos, uploaded by users, or generated as Identicons as a placeholder. ## Basic example Add `.avatar` to any `` element to make it an avatar. This resets some key styles for alignment, address a Firefox image placeholder bug, and rounds the corners. Be sure to set `width` and `height` attributes for maximum browser performance. ```html live jonrohan ``` ### Small avatars We occasionally use smaller avatars. Anything less than `24px` wide should include the `.avatar-small` modifier class to reset the `border-radius` to a more appropriate level. ```html live jonrohan ``` ### Avatar sizes Instead of using the `width` and `height` attribute, you can also use a class like `.avatar-[1-8]`. The sizes go from `16px` up to `64px`. Note: Avatar stacks are only suppurted for the `20px` avatar size. ```html live jonrohan jonrohan jonrohan jonrohan jonrohan jonrohan jonrohan jonrohan ``` ### Parent-child avatars When you need a larger parent avatar, and a smaller child one, overlaid slightly, use the parent-child classes. ```html live
jonrohan josh
``` ### Avatar stack Stacked avatars can be used to show multiple collaborators or participants when there is limited space available. When you hover over the stack, the avatars will reveal themselves. ```html live
@octocat @octocat @octocat
``` Based on the number of avatars in the stack, add these modifier classes: - `AvatarStack--two` for 2 avatars. - `AvatarStack--three-plus` for 3 or more avatars. If you have more than three avatars, add a div with the classes `avatar avatar-more` as the third avatar in the stack, as such: ```html live
@octocat @octocat
@octocat @octocat @octocat
``` You can also link individual avatars. To do this shift the `avatar` class over to the anchor: ```html live
@octocat @octocat
``` Use `AvatarStack--right` to right-align the avatar stack. Remember to switch the alignment of tooltips when making this change. ```html live
@octocat @octocat @octocat
``` ## Circle badge `.CircleBadge` allows for the display of badge-like icons or logos. They are used mostly with Octicons or partner integration icons. `.CircleBadge` should have an `aria-label`, `title` (for a link), or an `alt` (for child `img` elements) attribute specified if there is no text-based alternative to describe it. If there is a text-based alternative or the icon has no semantic value, `aria-hidden="true"` or an empty `alt` attribute may be used. ### Small ```html live ``` ### Medium ```html live
Travis CI
``` ### Large ```html live
Travis CI
``` ### Dashed connection For specific cases where two badges or more need to be shown as related or connected (such as integrations or specific product workflows), a `DashedConnection` class was created. Use utility classes to ensure badges are spaced correctly. ```html live
```