progress.mdx 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. ---
  2. title: Progress bars
  3. summary: Progress bars are used to provide feedback on an action status and inform users of the current progress. Although seemingly small interface elements, they are extremely hepful in managing users' expectations and preventing them from abandoning a process they have initiated.
  4. bootstrapLink: components/progress
  5. description: Track and display progress visually.
  6. ---
  7. ## Default markup
  8. To create a default progress bar, add a `.progress` class to a `<div>` element. Thanks to that, you will be able to notify users how long they have to wait for a process to complete.
  9. ```html example columns={1} centered
  10. <div class="progress">
  11. <div class="progress-bar" style="width: 38%"></div>
  12. </div>
  13. ```
  14. ```html
  15. <div class="progress">
  16. <div class="progress-bar" style="width: 38%" role="progressbar" aria-valuenow="38" aria-valuemin="0" aria-valuemax="100" aria-label="38% Complete">
  17. <span class="visually-hidden">38% Complete</span>
  18. </div>
  19. </div>
  20. ```
  21. ## Progress size
  22. Using Bootstrap’s typical naming structure, you can create a standard progress bar or scale it up or down to different sizes based on what’s needed.
  23. ```html
  24. <div class="progress progress-sm">...</div>
  25. ```
  26. Look at the example below to see how it works:
  27. ```html example columns={1} centered
  28. <div class="progress progress-sm">
  29. <div class="progress-bar" style="width: 57%" role="progressbar" aria-valuenow="57" aria-valuemin="0" aria-valuemax="100" aria-label="57% Complete">
  30. <span class="visually-hidden">57% Complete</span>
  31. </div>
  32. </div>
  33. ```
  34. ## Indeterminate progress
  35. You can create a progress bar which shows indeterminate progress by adding `.progress-bar-indeterminate` to the `.progress-bar` element.
  36. ```html example columns={1} centered
  37. <div class="progress progress-sm">
  38. <div class="progress-bar progress-bar-indeterminate"></div>
  39. </div>
  40. ```
  41. ## Native progress element
  42. You can also use native HTML5 `<progress>` element. It is a great way to create a progress bar without the need for additional HTML elements.
  43. ```html
  44. <progress class="progress progress-sm" value="15" max="100" />
  45. ```
  46. This is how it looks like:
  47. ```html example columns={1} centered
  48. <progress class="progress progress-sm" value="15" max="100" />
  49. ```
  50. ## Progress color
  51. You can change the color of the progress bar by adding a color class to the `.progress-bar` element. You can use the color classes like `.bg-primary`, `.bg-success`, etc. to change the color of the progress bar.
  52. Full list of available colors can be found [here](/docs/ui/base/colors).
  53. ```html example columns={1} centered separated
  54. <div class="progress">
  55. <div class="progress-bar bg-red" style="width: 24%" role="progressbar" aria-valuenow="24" aria-valuemin="0" aria-valuemax="100" aria-label="24% Complete">
  56. <span class="visually-hidden">24% Complete</span>
  57. </div>
  58. </div>
  59. <div class="progress">
  60. <div class="progress-bar bg-green" style="width: 45%" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" aria-label="45% Complete">
  61. <span class="visually-hidden">45% Complete</span>
  62. </div>
  63. </div>
  64. <div class="progress">
  65. <div class="progress-bar bg-purple" style="width: 64%" role="progressbar" aria-valuenow="64" aria-valuemin="0" aria-valuemax="100" aria-label="64% Complete">
  66. <span class="visually-hidden">64% Complete</span>
  67. </div>
  68. </div>
  69. <div class="progress">
  70. <div class="progress-bar bg-blue" style="width: 38%" role="progressbar" aria-valuenow="38" aria-valuemin="0" aria-valuemax="100" aria-label="38% Complete">
  71. <span class="visually-hidden">38% Complete</span>
  72. </div>
  73. </div>
  74. ```
  75. ## Multiple progress bars
  76. You can stack multiple progress bars on top of each other to create a visually appealing design. This can be done by adding multiple `.progress` elements inside a `.progress-stacked` container.
  77. ```html
  78. <div class="progress-stacked">
  79. <div class="progress">...</div>
  80. </div>
  81. ```
  82. This is how it looks like:
  83. ```html example columns={2} centered
  84. <div class="progress-stacked">
  85. <div class="progress" style="width: 15%">
  86. <div class="progress-bar"></div>
  87. </div>
  88. <div class="progress" style="width: 30%">
  89. <div class="progress-bar bg-success"></div>
  90. </div>
  91. <div class="progress" style="width: 20%">
  92. <div class="progress-bar bg-info"></div>
  93. </div>
  94. </div>
  95. ```
  96. ## Striped progress
  97. You can create a striped progress bar by adding the `.progress-bar-striped` class to the `.progress-bar` element.
  98. ```html
  99. <div class="progress">
  100. <div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 60%"></div>
  101. </div>
  102. ```
  103. This is how it looks like:
  104. ```html example columns={1} centered separated
  105. <div class="progress">
  106. <div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 60%"></div>
  107. </div>
  108. ```
  109. ## Progress background
  110. By using a progress bar component as a background element, designers can create a dynamic and engaging visual experience for users. For example, the progress bar could be used to represent the completion of a long-term goal or project, such as a fundraising campaign or construction project. As users interact with the page, the progress bar could gradually fill up, creating a sense of momentum and progress.
  111. ```html
  112. <div class="progressbg">
  113. <div class="progress progressbg-progress">
  114. <div class="progress-bar bg-primary-lt" style="width: 65%"></div>
  115. </div>
  116. <div class="progressbg-text">Poland</div>
  117. <div class="progressbg-value">65%</div>
  118. </div>
  119. ```
  120. Thanks to this you can create a nice looking statistics section:
  121. ```html example vertical separated centered columns={1} plugins="flags" height="20rem"
  122. <div class="progressbg">
  123. <div class="progress progressbg-progress">
  124. <div class="progress-bar bg-primary-lt" style="width: 65%"></div>
  125. </div>
  126. <div class="progressbg-text">Poland</div>
  127. <div class="progressbg-value">65%</div>
  128. </div>
  129. <div class="progressbg">
  130. <div class="progress progressbg-progress">
  131. <div class="progress-bar bg-primary-lt" style="width: 35%"></div>
  132. </div>
  133. <div class="progressbg-text">Germany</div>
  134. <div class="progressbg-value">35%</div>
  135. </div>
  136. <div class="progressbg">
  137. <div class="progress progressbg-progress">
  138. <div class="progress-bar bg-primary-lt" style="width: 28%"></div>
  139. </div>
  140. <div class="progressbg-text">United Stated</div>
  141. <div class="progressbg-value">28%</div>
  142. </div>
  143. <div class="progressbg">
  144. <div class="progress progressbg-progress">
  145. <div class="progress-bar bg-primary-lt" style="width: 20%"></div>
  146. </div>
  147. <div class="progressbg-text">United Kingdom</div>
  148. <div class="progressbg-value">20%</div>
  149. </div>
  150. <div class="progressbg">
  151. <div class="progress progressbg-progress">
  152. <div class="progress-bar bg-primary-lt" style="width: 15%"></div>
  153. </div>
  154. <div class="progressbg-text">France</div>
  155. <div class="progressbg-value">15%</div>
  156. </div>
  157. ```