1
1
mirror of https://github.com/primer/css.git synced 2024-12-26 15:43:59 +03:00
css/docs/content/components/progress.md

75 lines
2.6 KiB
Markdown
Raw Normal View History

2019-07-30 02:56:17 +03:00
---
title: Progress
path: components/progress
2019-08-15 00:59:37 +03:00
status: New
2019-07-30 02:56:17 +03:00
source: 'https://github.com/primer/css/tree/master/src/progress'
bundle: progress
---
2020-06-29 15:09:36 +03:00
Use progress components to visualize task completion. The `Progress` class adds a background color and aligns its children horizontally with flexbox. The children (`Progress-item`) should be individually colored with [background utilities](/utilities/colors#background-colors) and sized with inline `width` styles in percentages. Overflow is hidden, so children that overflow will be clipped.
2019-07-30 02:56:17 +03:00
2019-08-09 01:24:04 +03:00
```html live
2019-07-30 02:56:17 +03:00
<span class="Progress">
2020-06-29 15:09:36 +03:00
<span class="Progress-item bg-green" style="width: 50%;"></span>
2019-07-30 02:56:17 +03:00
</span>
```
2020-04-02 16:18:44 +03:00
## Large progress
2019-08-15 00:59:37 +03:00
2019-07-30 02:56:17 +03:00
Large progress bars are slightly taller than the default.
2019-08-09 01:24:04 +03:00
```html live
2019-07-30 02:56:17 +03:00
<span class="Progress Progress--large">
2020-06-29 15:09:36 +03:00
<span class="Progress-item bg-green" style="width: 50%;"></span>
2019-07-30 02:56:17 +03:00
</span>
```
2020-04-02 16:18:44 +03:00
## Small progress
2019-08-15 00:59:37 +03:00
Small progress bars are shorter than the default.
2019-07-30 02:56:17 +03:00
2019-08-09 01:24:04 +03:00
```html live
2019-07-30 02:56:17 +03:00
<span class="Progress Progress--small">
2020-06-29 15:09:36 +03:00
<span class="Progress-item bg-green" style="width: 50%;"></span>
2019-07-30 02:56:17 +03:00
</span>
```
2020-04-02 16:18:44 +03:00
## Inline progress
2019-08-15 00:59:37 +03:00
2019-07-30 02:56:17 +03:00
For inline progress indicators, use the `Progress` and `d-inline-flex` with an inline element such as `<span>` and add a custom `width` style:
2019-08-09 01:24:04 +03:00
```html live
2019-07-30 02:56:17 +03:00
<span class="text-small text-gray mr-2">4 of 16</span>
<span class="Progress d-inline-flex" style="width: 160px">
2020-06-29 15:09:36 +03:00
<div class="Progress-item bg-green" style="width: 25%"></div>
2019-07-30 02:56:17 +03:00
</span>
```
## Accessibility
2019-08-15 00:59:37 +03:00
2019-07-30 02:56:17 +03:00
In cases where it's not possible to describe the progress in text, provide an `aria-label` attribute that does so:
2019-08-09 01:24:04 +03:00
```html live
2019-07-30 02:56:17 +03:00
<div aria-label="tasks: 8 of 10 complete">
<span class="Progress">
2020-06-29 15:09:36 +03:00
<span class="Progress-item bg-green" style="width: 80%;"></span>
2019-07-30 02:56:17 +03:00
</span>
</div>
```
## Progress with multiple values
2019-08-15 00:59:37 +03:00
2020-05-19 08:38:18 +03:00
To show the progress of tasks in multiple states (such as "done", "in progress", and "open"), add the `Progress-item` class and a distinct background color utility. Then give each one a percentage width proportional to the total number. Children are stacked from left to right, so if your widths add up to 100%, your bars will too. Note that items with very low percentage values might not be visible if they are smaller than `1px` in width.
2019-07-30 02:56:17 +03:00
2019-08-09 01:24:04 +03:00
```html live
2019-07-30 02:56:17 +03:00
<div class="tooltipped tooltipped-n" aria-label="tasks: 80 done, 14 in progress, 6 open">
2020-05-19 08:38:18 +03:00
<span class="Progress">
2020-05-19 08:10:13 +03:00
<span class="Progress-item bg-green" style="width: 50%;"></span>
<span class="Progress-item bg-purple" style="width: 25%;"></span>
<span class="Progress-item bg-pink" style="width: 15%;"></span>
<span class="Progress-item bg-red" style="width: 8%;"></span>
<span class="Progress-item bg-blue" style="width: 2%;"></span>
2019-07-30 02:56:17 +03:00
</span>
</div>
```