Avatar Group

Description

Avatar Group displays two or more avatars in an inline stack.

PRO
This component is part of our professional component suite. See the installation instructions below for more on how to use it.

Arguments

Name Default Type Description
reverse Boolean Position items horizontally in the opposite direction.
html_attributes {} Hash Any attributes for the used html wrapper tag
Negative margins must be activated in bootstrap for this component. These negative margins are disabled by default, but can be enabled in Sass by setting $enable-negative-margins: true.

Examples

Default

<%= render Railsboot::AvatarGroupComponent.new do |avatar_group| %>
  <% avatar_group.with_avatar(src: "public/avatar/1.jpg", class: "border border-2 border-white") %>
  <% avatar_group.with_avatar(src: "public/avatar/2.jpg", class: "ms-n3 border border-2 border-white") %>
  <% avatar_group.with_avatar(src: "public/avatar/3.jpg", class: "ms-n3 border border-2 border-white") %>
  <% avatar_group.with_avatar(src: "public/avatar/4.jpg", class: "ms-n3 border border-2 border-white") %>
  <% avatar_group.with_avatar(letter: "+ 9", class: "ms-n3 border border-2 border-white") %>
<% end %>
<div class="d-flex">
  <div class="position-relative d-inline-block bg-primary rounded-circle border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/1-0e38f189533d5684d22d51f8343519b16e4ba323454de5a3b9e8a50fe4be1ef2.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/2-418080169b8fc440a2f1f5222a5b72eddbdf1a750c0f3fb4ddf01bf0b1a82210.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/3-c7d1dc546cf5030d37d03587546e5e9fde59fd946325d77565b995d49e24506b.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/4-d9b2768223571ee0bfba3a286c675eea05059b188b818c01b0f6f615fe7d01bb.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgYWxpZ25tZW50LWJhc2VsaW5lPSJtaWRkbGUiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZvbnQtZmFtaWx5PSJBcmlhbCIgZm9udC1zaXplPSI0MCIgZHk9Ii4xZW0iIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiIGZpbGw9IndoaXRlIj4KICAgICsgOQogIDwvdGV4dD4KPC9zdmc+Cg==" width="32" height="32" />
  </div>
</div>

Reverse

<%= render Railsboot::AvatarGroupComponent.new(reverse: true) do |avatar_group| %>
  <% avatar_group.with_avatar(src: "public/avatar/1.jpg", class: "border border-2 border-white") %>
  <% avatar_group.with_avatar(src: "public/avatar/2.jpg", class: "ms-n3 border border-2 border-white") %>
  <% avatar_group.with_avatar(src: "public/avatar/3.jpg", class: "ms-n3 border border-2 border-white") %>
  <% avatar_group.with_avatar(src: "public/avatar/4.jpg", class: "ms-n3 border border-2 border-white") %>
  <% avatar_group.with_avatar(letter: "+ 9", class: "ms-n3 border border-2 border-white") %>
<% end %>
<div class="d-flex" style="flex-direction: row-reverse; justify-content: flex-end;">
  <div class="position-relative d-inline-block bg-primary rounded-circle border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/1-0e38f189533d5684d22d51f8343519b16e4ba323454de5a3b9e8a50fe4be1ef2.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/2-418080169b8fc440a2f1f5222a5b72eddbdf1a750c0f3fb4ddf01bf0b1a82210.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/3-c7d1dc546cf5030d37d03587546e5e9fde59fd946325d77565b995d49e24506b.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="https://railsbootui.com/assets/public/avatar/4-d9b2768223571ee0bfba3a286c675eea05059b188b818c01b0f6f615fe7d01bb.jpg" width="32" height="32" />
  </div>
  <div class="position-relative d-inline-block bg-primary rounded-circle ms-n3 border border-2 border-white" style="width: 32px; height: 32px; box-sizing: content-box;">
    <img alt="" class="rounded-circle" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgYWxpZ25tZW50LWJhc2VsaW5lPSJtaWRkbGUiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZvbnQtZmFtaWx5PSJBcmlhbCIgZm9udC1zaXplPSI0MCIgZHk9Ii4xZW0iIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiIGZpbGw9IndoaXRlIj4KICAgICsgOQogIDwvdGV4dD4KPC9zdmc+Cg==" width="32" height="32" />
  </div>
</div>

Installation

Simply download this component with all its related files and assets. Unpackage the downloaded ZIP-file, copy all relevant files into your app and adapt the things you need. The ZIP-folder contains:

  • A parent component class (app/components/railsboot/component.rb) of which all components inherit from.
  • A base component class (app/components/railsboot/base_component.rb) which is used for rendering internally.
  • The desired component itself (app/components/railsboot/avatar_group_component.rb).
  • A view template (app/components/railsboot/avatar_group_component.html.erb) for the component unless it's rendered inline.
  • Any other dependent components such as Slots (just if the component needs those)
  • Any dependent assets (JS-Files, CSS-Files) (just if the component needs those)
  • A test file for the components (test/components/railsboot/avatar_group_component_test.rb) including potential slot or dependency tests.

For more information please refer to the installation section.

Download

Download the component and its related files (e.g. templates, assets, slots etc.), unpackage the zip file and adapt the things you need.

Get access You need to purchase a professional license to download this component.