placeholder.mdx 8.6 KB

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