From a0141aa38e74108b4b5f805f8af65cb618236823 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 29 Dec 2016 14:56:28 -0800 Subject: Rewrite progress component without element - element didn't allow animation, labels overlaid, multiple bars, etc. - Revamps CSS to use something more similar to v3's implementation - Ditches variant mixin for `bg-` utils - Rebuilds docs to match, including adding a new Height section for customizing that. Only potential remaining todo is adding `.sr-only` instances to within the bar. Unsure if that's necessary. --- docs/components/progress.md | 128 +++++++++++++++++++++++++++++++++----------- 1 file changed, 98 insertions(+), 30 deletions(-) (limited to 'docs/components/progress.md') diff --git a/docs/components/progress.md b/docs/components/progress.md index d137fad14..29436c365 100644 --- a/docs/components/progress.md +++ b/docs/components/progress.md @@ -5,71 +5,139 @@ description: Documentation and examples for using Bootstrap progress bars. group: components --- -Stylize [the HTML5 `` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress) with a few extra classes and some crafty browser-specific CSS. Be sure to read up on the browser support. +Use our custom progress component for displaying simple or complex progress bars. We don't use [the HTML5 `` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress), ensuring you can stack progress bars, animate them, and place text labels over them. ## Contents * Will be replaced with the ToC, excluding the "Contents" header {:toc} -## Example +## How it works -To caption a progress bar, simply add a `
` with your caption text, [align the text using a utility class]({{ site.baseurl }}/utilities/typography/#text-alignment), and associate the caption with the `` element using the `aria-describedby` attribute. +Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. + +- We use the `.progress` as a wrapper to indicate the max value of the progress bar. +- We use the inner `.progress-bar` to indicate the progress so far. +- The `.progress-bar` requires an inline style or custom CSS to set their width. +- The `.progress-bar` also requires some `role` and `aria` attributes to make it accessible. + +Put that all together, and you have the following examples. {% example html %} +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% endexample %} -
Reticulating splines… 0%
- +## Customizing -
Reticulating splines… 25%
- +Customize the appearance of your progress bars with custom CSS, background utilities, stripes, and more. -
Reticulating splines… 50%
- +### Labels -
Reticulating splines… 75%
- +Add labels to your progress bars by placing text within the `.progress-bar`. -
Reticulating splines… 100%
- +{% example html %} +
+
25%
+
{% endexample %} -## Contextual alternatives +### Height -Progress bars use some of the same button and alert classes for consistent styles. +We only set a `height` value on the `.progress-bar`, so if you change that value the outer `.progress` will automatically resize accordingly. {% example html %} - - - - +
+
+
+
+
+
+{% endexample %} + +### Backgrounds + +Use background utility classes to change the appearance of individual progress bars. + +{% example html %} +
+
+
+
+
+
+
+
+
+
+
+
+{% endexample %} + +### Multiple bars + +Include multiple progress bars in a progress component if you need. + +{% example html %} +
+
+
+
+
{% endexample %} ### Striped -Uses a gradient to create a striped effect. +Add `.progress-bar-striped` to any `.progress-bar` to apply a stripe via CSS gradient over the progress bar's background color. {% example html %} - - - - - +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{% endexample %} ### Animated stripes -The striped gradient can also be animated. Add `.progress-animated` to `.progress` to animate the stripes right to left via CSS3 animations. +The striped gradient can also be animated. Add `.progress-bar-animated` to `.progress-bar` to animate the stripes right to left via CSS3 animations. -**Animated progress bars don't work in Opera 12**—as they don't support CSS3 animations. They also **don't work in IE10+ and Microsoft Edge** as those browsers currently don't support CSS3 animations on the [`::-ms-fill` pseudo-element](https://msdn.microsoft.com/en-us/library/windows/apps/hh465757.aspx). +**Animated progress bars don't work in Opera 12**—as they don't support CSS3 animations.
- -
{% highlight html %} - +
+
+
{% endhighlight %} -- cgit v1.2.3