You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docs: improve progress bar labels markup and explanations for accessibility (#39364)
* Docs: improve progress bar labels markup and explanations for accessibility
* Update site/content/docs/5.3/components/progress.md
---------
Co-authored-by: Mark Otto <[email protected]>
Copy file name to clipboardexpand all lines: site/content/docs/5.3/components/progress.md
+13-19
Original file line number
Diff line number
Diff line change
@@ -75,13 +75,15 @@ Add labels to your progress bars by placing text within the `.progress-bar`.
75
75
</div>
76
76
{{< /example >}}
77
77
78
-
Note that by default, the content inside the `.progress-bar` is controlled with `overflow: hidden`, so it doesn't bleed out of the bar. If your progress bar is shorter than its label, the content will be capped and may become unreadable. To change this behavior, you can use `.overflow-visible` from the [overflow utilities]({{< docsref "/utilities/overflow" >}}), but make sure to also define an explicit [text color]({{< docsref "/utilities/colors#colors" >}}) so the text remains readable. Be aware though that currently this approach does not take into account [color modes]({{< docsref "/customize/color-modes" >}}).
78
+
### Long labels
79
79
80
-
{{< example >}}
81
-
<divclass="progress"role="progressbar"aria-label="Example with label"aria-valuenow="10"aria-valuemin="0"aria-valuemax="100">
82
-
<divclass="progress-bar overflow-visible text-dark"style="width: 10%">Long label text for the progress bar, set to a dark color</div>
83
-
</div>
84
-
{{< /example >}}
80
+
Note that by default, the content inside the `.progress-bar` is controlled with `overflow: hidden`, so it doesn't bleed out of the bar. If your progress bar is shorter than its label, the content will be capped and may become unreadable. To change this behavior, you can use `.overflow-visible` from the [overflow utilities]({{< docsref "/utilities/overflow" >}}).
81
+
82
+
{{< callout warning >}}
83
+
Labels longer than the progress bar within may not be fully accessible using this method because it relies on the text color having the correct contrast ratio with both the `.progress` and `.progress-bar` background colors. Use caution when implementing this example.
84
+
85
+
If the text can overlap the progress bar, we often recommend displaying the label outside of the progress bar for better accessibility.
86
+
{{< /callout >}}
85
87
86
88
## Backgrounds
87
89
@@ -106,28 +108,20 @@ Use background utility classes to change the appearance of individual progress b
If you're adding labels to progress bars with a custom background color, make sure to also set an appropriate [text color]({{< docsref "/utilities/colors#colors" >}}), so the labels remain readable and have sufficient contrast.
111
+
If you're adding labels to progress bars with a custom background color, make sure to also set an appropriate [text color]({{< docsref "/utilities/colors#colors" >}}), so the labels remain readable and have sufficient contrast. We recommend using the [color and background]({{< docsref "/helpers/color-background" >}}) helper classes.
0 commit comments