Skip to content

Avatar

Beta
Use avatars to represent users or organizations.

Avatar can be used to represent users and organizations on GitHub.

  • Use the default circle avatar for users, and the square shape for organizations or any other non-human avatars.
  • By default, Avatar will render a static <img>. To have Avatar function as a link, set the href which will wrap the <img> in a <a>.
  • Set size to update the height and width of the Avatar in pixels.
  • To stack multiple avatars together, use AvatarStack.

Accessibility

Images should have text alternatives that describe the information or function represented. If the avatar functions as a link, provide alt text that helps convey the function. For instance, if Avatar is a link to a user profile, the alt attribute should be @kittenuser profile rather than @kittenuser. Learn more about best image practices (WAI Images)

Arguments

NameTypeDefaultDescription
srcStringN/AThe source url of the avatar image.
altStringN/APassed through to alt on img tag.
sizeInteger20One of 16, 20, 24, 32, 40, 48, or 80.
shapeSymbol:circleShape of the avatar. One of :circle and :square.
hrefStringnilThe URL to link to. If used, component will be wrapped by an <a> tag.
system_argumentsHashN/ASystem arguments

Examples

Default

@kittenuser
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>

Square

@kittenuser
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", shape: :square)) %>
@kittenuser profile
<%= render(Primer::Beta::Avatar.new(href: "#", src: "http://placekitten.com/200/200", alt: "@kittenuser profile")) %>

With size

@kittenuser@kittenuser@kittenuser@kittenuser@kittenuser@kittenuser@kittenuser
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 16)) %>
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 20)) %>
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 24)) %>
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 32)) %>
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 40)) %>
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 48)) %>
<%= render(Primer::Beta::Avatar.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 80)) %>