avatars.mdx 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. ---
  2. title: Avatars
  3. description: 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. ---
  5. ## Default markup
  6. Use the `avatar` class to add an avatar to your interface design for greater customisation.
  7. ```html example centered separated code
  8. <span class="avatar" style="background-image: url(/samples/avatars/002f.jpg)"></span>
  9. <span class="avatar">JL</span>
  10. <span class="avatar" style="background-image: url(/samples/avatars/004f.jpg)"></span>
  11. ```
  12. ## Avatar image
  13. Set an image as the background to make users easy to indentify and create a personalised experience.
  14. ```html example centered separated code
  15. <span class="avatar" style="background-image: url(/samples/avatars/016f.jpg)"></span>
  16. <span class="avatar" style="background-image: url(/samples/avatars/022m.jpg)"></span>
  17. <span class="avatar" style="background-image: url(/samples/avatars/036m.jpg)"></span>
  18. ```
  19. ## Initials
  20. You can also use initials instead of pictures.
  21. ```html example centered separated code
  22. <span class="avatar">AB</span>
  23. <span class="avatar">CD</span>
  24. <span class="avatar">EF</span>
  25. <span class="avatar">GH</span>
  26. <span class="avatar">IJ</span>
  27. ```
  28. ## Avatar icons
  29. Apart from pictures and initials, you can also use icons to make the avatars more universal.
  30. ```html example centered separated
  31. <span class="avatar">
  32. <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">
  33. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  34. <circle cx="12" cy="7" r="4" />
  35. <path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
  36. </svg>
  37. </span>
  38. <span class="avatar">
  39. <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">
  40. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  41. <line x1="12" y1="5" x2="12" y2="19" />
  42. <line x1="5" y1="12" x2="19" y2="12" />
  43. </svg>
  44. </span>
  45. <span class="avatar">
  46. <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">
  47. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  48. <circle cx="9" cy="7" r="4" />
  49. <path d="M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
  50. <path d="M16 11h6m-3 -3v6" />
  51. </svg>
  52. </span>
  53. ```
  54. ```html
  55. <span class="avatar">
  56. <!-- SVG icon from http://tabler-icons.io/i/user -->
  57. <svg>...</svg>
  58. </span>
  59. ```
  60. ## Avatar initials color
  61. Customize the color of the avatars' background. You can click [here](colors) to see the list of available colors.
  62. ```html example centered separated code
  63. <span class="avatar bg-green-lt">AB</span>
  64. <span class="avatar bg-red-lt">CD</span>
  65. <span class="avatar bg-yellow-lt">EF</span>
  66. <span class="avatar bg-primary-lt">GH</span>
  67. <span class="avatar bg-purple-lt">IJ</span>
  68. ```
  69. ## Avatar size
  70. 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.
  71. ```html example centered separated code
  72. <span class="avatar avatar-xl" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  73. <span class="avatar avatar-lg" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  74. <span class="avatar avatar-md" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  75. <span class="avatar" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  76. <span class="avatar avatar-sm" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  77. <span class="avatar avatar-xs" style="background-image: url(/samples/avatars/000m.jpg)"></span>
  78. ```
  79. ## Avatar status
  80. 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.
  81. ```html example centered separated code
  82. <span class="avatar" style="background-image: url(/samples/avatars/018m.jpg)"></span>
  83. <span class="avatar" style="background-image: url(/samples/avatars/015m.jpg)">
  84. <span class="badge bg-danger"></span>
  85. </span>
  86. <span class="avatar" style="background-image: url(/samples/avatars/022m.jpg)">
  87. <span class="badge bg-success"></span>
  88. </span>
  89. <span class="avatar"><span class="badge bg-warning"></span>SA</span>
  90. <span class="avatar" style="background-image: url(/samples/avatars/022m.jpg)">
  91. <span class="badge bg-info"></span>
  92. </span>
  93. <span class="avatar" style="background-image: url(/samples/avatars/048m.jpg)">
  94. <span class="badge bg-gray">5</span>
  95. </span>
  96. ```
  97. ## Avatar shape
  98. Change the shape of an avatar with the default Bootstrap image classes. You can make them round or square and change their border radius.
  99. ```html example centered separated
  100. <span class="avatar" style="background-image: url(/samples/avatars/019m.jpg)"></span>
  101. <span class="avatar rounded" style="background-image: url(/samples/avatars/039f.jpg)"></span>
  102. <span class="avatar rounded-circle">AA</span>
  103. <span class="avatar rounded-0" style="background-image: url(/samples/avatars/043f.jpg)"></span>
  104. <span class="avatar rounded-3" style="background-image: url(/samples/avatars/044f.jpg)"></span>
  105. ```
  106. ## Avatars list
  107. Create a list of avatars within one parent container.
  108. ```html example centered separated code
  109. <div class="avatar-list">
  110. <span class="avatar rounded" style="background-image: url(/samples/avatars/031f.jpg)"></span>
  111. <span class="avatar rounded">JL</span>
  112. <span class="avatar rounded" style="background-image: url(/samples/avatars/033f.jpg)"></span>
  113. <span class="avatar rounded" style="background-image: url(/samples/avatars/017m.jpg)"></span>
  114. <span class="avatar rounded" style="background-image: url(/samples/avatars/024m.jpg)"></span>
  115. </div>
  116. ```
  117. ## Stacked list
  118. 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.
  119. ```html example centered separated code
  120. <div class="avatar-list avatar-list-stacked">
  121. <span class="avatar">EB</span>
  122. <span class="avatar" style="background-image: url(/samples/avatars/026m.jpg)"></span>
  123. <span class="avatar" style="background-image: url(/samples/avatars/016f.jpg)"></span>
  124. <span class="avatar" style="background-image: url(/samples/avatars/028m.jpg)"></span>
  125. <span class="avatar" style="background-image: url(/samples/avatars/030m.jpg)"></span>
  126. <span class="avatar">+8</span>
  127. </div>
  128. ```
  129. ```html example centered separated code
  130. <div class="avatar-list avatar-list-stacked">
  131. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/035m.jpg)"></span>
  132. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/027f.jpg)"></span>
  133. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/036f.jpg)"></span>
  134. <span class="avatar avatar-sm rounded-circle">SA</span>
  135. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/034f.jpg)"></span>
  136. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/043f.jpg)"></span>
  137. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/039f.jpg)"></span>
  138. <span class="avatar avatar-sm rounded-circle" style="background-image: url(/samples/avatars/020m.jpg)"></span>
  139. </div>
  140. ```