avatars.mdx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ---
  2. title: Avatars
  3. summary: Avatars help customise various elements of a user interface and make the product experience more personalised. They are often used in communication apps, collaboration tools and social media.
  4. description: Personalize UI with user avatars.
  5. ---
  6. ## Default markup
  7. Use the `avatar` class to add an avatar to your interface design for greater customisation.
  8. ```html example centered separated code
  9. <span class="avatar" style="background-image: url(/samples/avatars/002f.jpg)"></span>
  10. <span class="avatar">JL</span>
  11. <span class="avatar" style="background-image: url(/samples/avatars/004f.jpg)"></span>
  12. ```
  13. ## Avatar image
  14. Set an image as the background to make users easy to indentify and create a personalised experience.
  15. ```html example centered separated code
  16. <span class="avatar" style="background-image: url(/samples/avatars/016f.jpg)"></span>
  17. <span class="avatar" style="background-image: url(/samples/avatars/022m.jpg)"></span>
  18. <span class="avatar" style="background-image: url(/samples/avatars/036m.jpg)"></span>
  19. ```
  20. ## Initials
  21. You can also use initials instead of pictures.
  22. ```html example centered separated code
  23. <span class="avatar">AB</span>
  24. <span class="avatar">CD</span>
  25. <span class="avatar">EF</span>
  26. <span class="avatar">GH</span>
  27. <span class="avatar">IJ</span>
  28. ```
  29. ## Avatar icons
  30. Apart from pictures and initials, you can also use icons to make the avatars more universal.
  31. ```html example centered separated
  32. <span class="avatar">
  33. <svg xmlns="http://www.w3.org/2000/svg" class="icon avatar-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  34. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  35. <circle cx="12" cy="7" r="4" />
  36. <path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
  37. </svg>
  38. </span>
  39. <span class="avatar">
  40. <svg xmlns="http://www.w3.org/2000/svg" class="icon avatar-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  41. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  42. <line x1="12" y1="5" x2="12" y2="19" />
  43. <line x1="5" y1="12" x2="19" y2="12" />
  44. </svg>
  45. </span>
  46. <span class="avatar">
  47. <svg xmlns="http://www.w3.org/2000/svg" class="icon avatar-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  48. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  49. <circle cx="9" cy="7" r="4" />
  50. <path d="M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
  51. <path d="M16 11h6m-3 -3v6" />
  52. </svg>
  53. </span>
  54. ```
  55. ```html
  56. <span class="avatar">
  57. <!-- SVG icon from http://tabler.io/icons/icon/user -->
  58. <svg>...</svg>
  59. </span>
  60. ```
  61. ## Avatar initials color
  62. Customize the color of the avatars' background. You can click [here](/docs/ui/base/colors) to see the list of available colors.
  63. ```html example centered separated code
  64. <span class="avatar bg-green-lt">AB</span>
  65. <span class="avatar bg-red-lt">CD</span>
  66. <span class="avatar bg-yellow-lt">EF</span>
  67. <span class="avatar bg-primary-lt">GH</span>
  68. <span class="avatar bg-purple-lt">IJ</span>
  69. ```
  70. ## Avatar size
  71. Using Bootstrap’s typical naming structure, you can create a standard avatar or scale it up or down to different sizes based on what you need.
  72. ```html example centered separated code
  73. <span class="avatar avatar-xl" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  74. <span class="avatar avatar-lg" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  75. <span class="avatar avatar-md" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  76. <span class="avatar" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  77. <span class="avatar avatar-sm" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  78. <span class="avatar avatar-xs" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  79. ```
  80. ## Avatar status
  81. Add a status indicator to your avatar to show, for instance, if a users is online or offline or indicate the number of messages they have received.
  82. ```html example centered separated code
  83. <span class="avatar" style="background-image: url(/samples/avatars/018m.jpg)"></span>
  84. <span class="avatar" style="background-image: url(/samples/avatars/015m.jpg)">
  85. <span class="badge bg-danger"></span>
  86. </span>
  87. <span class="avatar" style="background-image: url(/samples/avatars/022m.jpg)">
  88. <span class="badge bg-success"></span>
  89. </span>
  90. <span class="avatar">
  91. <span class="badge bg-warning"></span>SA
  92. </span>
  93. <span class="avatar" style="background-image: url(/samples/avatars/022m.jpg)">
  94. <span class="badge bg-info"></span>
  95. </span>
  96. <span class="avatar" style="background-image: url(/samples/avatars/048m.jpg)">
  97. <span class="badge bg-gray">5</span>
  98. </span>
  99. ```
  100. ## Avatar shape
  101. Change the shape of an avatar with the default Bootstrap image classes. You can make them round or square and change their border radius.
  102. ```html example centered separated
  103. <span class="avatar" style="background-image: url(/samples/avatars/019m.jpg)"></span>
  104. <span class="avatar rounded" style="background-image: url(/samples/avatars/039f.jpg)"></span>
  105. <span class="avatar rounded-circle">AA</span>
  106. <span class="avatar rounded-0" style="background-image: url(/samples/avatars/043f.jpg)"></span>
  107. <span class="avatar rounded-3" style="background-image: url(/samples/avatars/044f.jpg)"></span>
  108. ```
  109. ## Avatars list
  110. Create a list of avatars within one parent container.
  111. ```html example centered separated code
  112. <div class="avatar-list">
  113. <span class="avatar rounded" style="background-image: url(/samples/avatars/031f.jpg)"></span>
  114. <span class="avatar rounded">JL</span>
  115. <span class="avatar rounded" style="background-image: url(/samples/avatars/033f.jpg)"></span>
  116. <span class="avatar rounded" style="background-image: url(/samples/avatars/017m.jpg)"></span>
  117. <span class="avatar rounded" style="background-image: url(/samples/avatars/024m.jpg)"></span>
  118. </div>
  119. ```
  120. ## Stacked list
  121. Make the list stack once a certain number of avatars is reached to make it look clear and display well regardless of the screen size.
  122. ```html example centered separated code
  123. <div class="avatar-list avatar-list-stacked">
  124. <span class="avatar">EB</span>
  125. <span class="avatar" style="background-image: url(/samples/avatars/026m.jpg)"></span>
  126. <span class="avatar" style="background-image: url(/samples/avatars/016f.jpg)"></span>
  127. <span class="avatar" style="background-image: url(/samples/avatars/028m.jpg)"></span>
  128. <span class="avatar" style="background-image: url(/samples/avatars/030m.jpg)"></span>
  129. <span class="avatar">+8</span>
  130. </div>
  131. ```
  132. ```html example centered separated code
  133. <div class="avatar-list avatar-list-stacked">
  134. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/035m.jpg)"></span>
  135. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/027f.jpg)"></span>
  136. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/036f.jpg)"></span>
  137. <span class="avatar avatar-sm rounded-circle">SA</span>
  138. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/034f.jpg)"></span>
  139. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/043f.jpg)"></span>
  140. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/039f.jpg)"></span>
  141. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/020m.jpg)"></span>
  142. </div>
  143. ```