placeholder.mdx 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. ---
  2. title: Placeholder
  3. summary: Placeholder is used to reserve space for content that soon will appear in a layout.
  4. description: Reserve space for upcoming content.
  5. ---
  6. ## Placeholder line
  7. Placeholder lines can contain have lines of text. Their length is different and depends on the `col-` class.
  8. ```html example columns={1}
  9. <div class="placeholder col-9"></div>
  10. <div class="placeholder col-11"></div>
  11. <div class="placeholder col-10"></div>
  12. <div class="placeholder col-8"></div>
  13. ```
  14. However, it may be useful, however, to specify the full width in order to fit the content more effectively.
  15. ```html example columns={1}
  16. <div class="placeholder col-12"></div>
  17. <div class="placeholder col-12"></div>
  18. <div class="placeholder col-12"></div>
  19. <div class="placeholder col-12"></div>
  20. ```
  21. You can also move the lines to right or to center:
  22. ```html example columns={1}
  23. <div class="text-end">
  24. <div class="placeholder col-11"></div>
  25. <div class="placeholder col-10"></div>
  26. <div class="placeholder col-8"></div>
  27. </div>
  28. <div class="text-center mt-3">
  29. <div class="placeholder col-11"></div>
  30. <div class="placeholder col-10"></div>
  31. <div class="placeholder col-8"></div>
  32. </div>
  33. ```
  34. ## Placeholder heading
  35. A placeholder can contain also a header element looks like header:
  36. ```html example columns={1}
  37. <div class="placeholder col-9 mb-3"></div>
  38. <div class="placeholder placeholder-xs col-10"></div>
  39. <div class="placeholder placeholder-xs col-11"></div>
  40. ```
  41. ## Placeholder avatar
  42. You can use a placeholder, which will look like an avatar. You can use the `avatar` component, and get the image in the right proportions.
  43. ```html
  44. <div class="avatar placeholder"></div>
  45. ```
  46. Look at the example below to see how the avatar placeholder looks like.
  47. ```html example columns={1} centered
  48. <div class="row">
  49. <div class="col-auto">
  50. <div class="avatar placeholder"></div>
  51. </div>
  52. <div class="col">
  53. <div class="placeholder col-9"></div>
  54. <div class="placeholder col-11"></div>
  55. </div>
  56. </div>
  57. ```
  58. You can also use the `avatar` component with different sizes. Look at the example below to see how the avatar placeholder looks like.
  59. ```html example centered separated
  60. <div class="avatar avatar-xl placeholder"></div>
  61. <div class="avatar avatar-lg placeholder"></div>
  62. <div class="avatar avatar-md placeholder"></div>
  63. <div class="avatar placeholder"></div>
  64. <div class="avatar avatar-sm placeholder"></div>
  65. <div class="avatar avatar-xs placeholder"></div>
  66. ```
  67. ## Placeholder image
  68. You can use a placeholder, which will look like a picture. You can use the `ratio` component, and get the image in the right proportions.
  69. You can also use the `ratio` component, and get the image in the right proportions.
  70. ```html example columns={1} height={500} scrollable separated vertical
  71. <div class="ratio ratio-1x1 placeholder">
  72. <div class="placeholder-image"></div>
  73. </div>
  74. <div class="ratio ratio-4x3 placeholder">
  75. <div class="placeholder-image"></div>
  76. </div>
  77. <div class="ratio ratio-16x9 placeholder">
  78. <div class="placeholder-image"></div>
  79. </div>
  80. <div class="ratio ratio-21x9 placeholder">
  81. <div class="placeholder-image"></div>
  82. </div>
  83. ```
  84. ## Placeholder color
  85. By default, the `placeholder` uses `currentColor`. This can be overridden with a custom color or utility class. Full color classes are available for background colors.
  86. ```html
  87. <span class="placeholder col-12 bg-dark"></span>
  88. ```
  89. Look at the example below to see how the color affects the placeholder.
  90. ```html example columns={1} height={240}
  91. <span class="placeholder col-12"></span>
  92. <span class="placeholder col-12 bg-primary"></span>
  93. <span class="placeholder col-12 bg-secondary"></span>
  94. <span class="placeholder col-12 bg-success"></span>
  95. <span class="placeholder col-12 bg-danger"></span>
  96. <span class="placeholder col-12 bg-warning"></span>
  97. <span class="placeholder col-12 bg-info"></span>
  98. <span class="placeholder col-12 bg-light"></span>
  99. <span class="placeholder col-12 bg-dark"></span>
  100. ```
  101. ## Placeholder sizing
  102. The size of `.placeholders` are based on the typographic style of the parent element. Customize them with sizing modifiers: `.placeholder-lg`, `.placeholder-sm`, or `.placeholder-xs`.
  103. ```html example columns={1}
  104. <span class="placeholder col-12 placeholder-lg"></span>
  105. <span class="placeholder col-12"></span>
  106. <span class="placeholder col-12 placeholder-sm"></span>
  107. <span class="placeholder col-12 placeholder-xs"></span>
  108. ```
  109. ## Animation
  110. Animate placeholders with `.placeholder-glow` or `.placeholder-wave` to better convey the perception of something being actively loaded.
  111. ```html example columns={1}
  112. <p class="placeholder-glow">
  113. <span class="placeholder col-12"></span>
  114. </p>
  115. <p class="placeholder-wave">
  116. <span class="placeholder col-12"></span>
  117. </p>
  118. ```
  119. ## Live examples
  120. See in the following examples how else you can use the placeholder component
  121. ```html example columns={1} height={1000} separated vertical scrollable
  122. <div class="card placeholder-glow">
  123. <div class="ratio ratio-21x9 card-img-top placeholder"></div>
  124. <div class="card-body">
  125. <div class="placeholder col-9 mb-3"></div>
  126. <div class="placeholder placeholder-xs col-10"></div>
  127. <div class="placeholder placeholder-xs col-11"></div>
  128. <div class="mt-3">
  129. <a href="#" tabindex="-1" class="btn btn-primary disabled placeholder col-4" aria-hidden="true"></a>
  130. </div>
  131. </div>
  132. </div>
  133. <div class="card">
  134. <div class="row g-0 align-items-center placeholder-glow">
  135. <div class="col-3">
  136. <div class="ratio ratio-1x1 card-img-start placeholder"></div>
  137. </div>
  138. <div class="col">
  139. <div class="card-body">
  140. <div class="placeholder col-9 mb-3"></div>
  141. <div class="placeholder placeholder-xs col-10"></div>
  142. <div class="placeholder placeholder-xs col-11"></div>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. <div class="card">
  148. <div class="card-body">
  149. <div class="row">
  150. <div class="col-auto">
  151. <div class="avatar avatar-rounded placeholder"></div>
  152. </div>
  153. <div class="col">
  154. <div class="placeholder placeholder-xs col-9"></div>
  155. <div class="placeholder placeholder-xs col-7"></div>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. <div class="card">
  161. <div class="card-body py-5 text-center">
  162. <div>
  163. <div class="avatar avatar-rounded avatar-lg placeholder mb-3"></div>
  164. </div>
  165. <div class="mt w-75 mx-auto">
  166. <div class="placeholder col-9 mb-3"></div>
  167. <div class="placeholder placeholder-xs col-10"></div>
  168. </div>
  169. </div>
  170. </div>
  171. <div class="card">
  172. <ul class="list-group list-group-flush placeholder-glow">
  173. <li class="list-group-item">
  174. <div class="row align-items-center">
  175. <div class="col-auto">
  176. <div class="avatar avatar-rounded placeholder"></div>
  177. </div>
  178. <div class="col-7">
  179. <div class="placeholder placeholder-xs col-9"></div>
  180. <div class="placeholder placeholder-xs col-7"></div>
  181. </div>
  182. <div class="col-2 ms-auto text-end">
  183. <div class="placeholder placeholder-xs col-8"></div>
  184. <div class="placeholder placeholder-xs col-10"></div>
  185. </div>
  186. </div>
  187. </li>
  188. <li class="list-group-item">
  189. <div class="row align-items-center">
  190. <div class="col-auto">
  191. <div class="avatar avatar-rounded placeholder"></div>
  192. </div>
  193. <div class="col-7">
  194. <div class="placeholder placeholder-xs col-9"></div>
  195. <div class="placeholder placeholder-xs col-7"></div>
  196. </div>
  197. <div class="col-2 ms-auto text-end">
  198. <div class="placeholder placeholder-xs col-8"></div>
  199. <div class="placeholder placeholder-xs col-10"></div>
  200. </div>
  201. </div>
  202. </li>
  203. <li class="list-group-item">
  204. <div class="row align-items-center">
  205. <div class="col-auto">
  206. <div class="avatar avatar-rounded placeholder"></div>
  207. </div>
  208. <div class="col-7">
  209. <div class="placeholder placeholder-xs col-9"></div>
  210. <div class="placeholder placeholder-xs col-7"></div>
  211. </div>
  212. <div class="col-2 ms-auto text-end">
  213. <div class="placeholder placeholder-xs col-8"></div>
  214. <div class="placeholder placeholder-xs col-10"></div>
  215. </div>
  216. </div>
  217. </li>
  218. <li class="list-group-item">
  219. <div class="row align-items-center">
  220. <div class="col-auto">
  221. <div class="avatar avatar-rounded placeholder"></div>
  222. </div>
  223. <div class="col-7">
  224. <div class="placeholder placeholder-xs col-9"></div>
  225. <div class="placeholder placeholder-xs col-7"></div>
  226. </div>
  227. <div class="col-2 ms-auto text-end">
  228. <div class="placeholder placeholder-xs col-8"></div>
  229. <div class="placeholder placeholder-xs col-10"></div>
  230. </div>
  231. </div>
  232. </li>
  233. </ul>
  234. </div>
  235. ```