|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +title: Progress |
| 4 | +description: Documentation and examples for using BootCell custom progress bars featuring support for stacked bars, animated backgrounds, and text labels. |
| 5 | +group: Components |
| 6 | +--- |
| 7 | + |
| 8 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 9 | + |
| 10 | +import { Example } from '../../../source/component/Example'; |
| 11 | + |
| 12 | +## How it works |
| 13 | + |
| 14 | +Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. |
| 15 | +We don’t use the HTML5 `<progress>` element, ensuring you can stack progress bars, animate them, and place text labels over them. |
| 16 | + |
| 17 | +<Example> |
| 18 | + <Progress /> |
| 19 | + <Progress percent={25} /> |
| 20 | + <Progress percent={50} /> |
| 21 | + <Progress percent={75} /> |
| 22 | + <Progress percent={100} /> |
| 23 | +</Example> |
| 24 | + |
| 25 | +```TSX |
| 26 | +import { render, createCell, Fragment } from 'web-cell'; |
| 27 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 28 | + |
| 29 | +render( |
| 30 | + <Fragment> |
| 31 | + <Progress /> |
| 32 | + <Progress percent={25} /> |
| 33 | + <Progress percent={50} /> |
| 34 | + <Progress percent={75} /> |
| 35 | + <Progress percent={100} /> |
| 36 | + </Fragment> |
| 37 | +); |
| 38 | +``` |
| 39 | + |
| 40 | +## Labels |
| 41 | + |
| 42 | +Add labels to your progress bars by setting `label` property. |
| 43 | + |
| 44 | +<Example> |
| 45 | + <Progress label percent={25} /> |
| 46 | + <Progress label={percent => percent + ' percent'} percent={25} /> |
| 47 | +</Example> |
| 48 | + |
| 49 | +```TSX |
| 50 | +import { render, createCell, Fragment } from 'web-cell'; |
| 51 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 52 | + |
| 53 | +render( |
| 54 | + <Fragment> |
| 55 | + <Progress label percent={25} /> |
| 56 | + <Progress label={percent => percent + ' percent'} percent={25} /> |
| 57 | + </Fragment> |
| 58 | +); |
| 59 | +``` |
| 60 | + |
| 61 | +## Height |
| 62 | + |
| 63 | +We only set a `height` style value on the `<Progress />`, |
| 64 | +so if you change that value the inner `.progress-bar` will automatically resize accordingly. |
| 65 | + |
| 66 | +<Example> |
| 67 | + <Progress style={{ height: '1px' }} percent={25} /> |
| 68 | + <Progress style={{ height: '20px' }} percent={25} /> |
| 69 | +</Example> |
| 70 | + |
| 71 | +```TSX |
| 72 | +import { render, createCell, Fragment } from 'web-cell'; |
| 73 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 74 | + |
| 75 | +render( |
| 76 | + <Fragment> |
| 77 | + <Progress style={{ height: '1px' }} percent={25} /> |
| 78 | + <Progress style={{ height: '20px' }} percent={25} /> |
| 79 | + </Fragment> |
| 80 | +); |
| 81 | +``` |
| 82 | + |
| 83 | +## Backgrounds |
| 84 | + |
| 85 | +Use `status` property values to change the appearance of individual progress bars. |
| 86 | + |
| 87 | +<Example> |
| 88 | + <Progress status="success" percent={25} /> |
| 89 | + <Progress status="info" percent={50} /> |
| 90 | + <Progress status="warning" percent={75} /> |
| 91 | + <Progress status="danger" percent={100} /> |
| 92 | +</Example> |
| 93 | + |
| 94 | +```TSX |
| 95 | +import { render, createCell, Fragment } from 'web-cell'; |
| 96 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 97 | + |
| 98 | +render( |
| 99 | + <Fragment> |
| 100 | + <Progress status="success" percent={25} /> |
| 101 | + <Progress status="info" percent={50} /> |
| 102 | + <Progress status="warning" percent={75} /> |
| 103 | + <Progress status="danger" percent={100} /> |
| 104 | + </Fragment> |
| 105 | +); |
| 106 | +``` |
| 107 | + |
| 108 | +## Multiple bars |
| 109 | + |
| 110 | +Include multiple progress bars in a progress component if you need. |
| 111 | + |
| 112 | +<Example> |
| 113 | + <Progress |
| 114 | + bars={[ |
| 115 | + { percent: 15 }, |
| 116 | + { status: 'success', percent: 30 }, |
| 117 | + { status: 'info', percent: 20 } |
| 118 | + ]} |
| 119 | + /> |
| 120 | +</Example> |
| 121 | + |
| 122 | +```TSX |
| 123 | +import { render, createCell } from 'web-cell'; |
| 124 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 125 | + |
| 126 | +render( |
| 127 | + <Progress |
| 128 | + bars={[ |
| 129 | + { percent: 15 }, |
| 130 | + { status: 'success', percent: 30 }, |
| 131 | + { status: 'info', percent: 20 } |
| 132 | + ]} |
| 133 | + /> |
| 134 | +); |
| 135 | +``` |
| 136 | + |
| 137 | +## Striped |
| 138 | + |
| 139 | +Add `striped` property to any `<Progress />` to apply a stripe via CSS gradient over the progress bar’s background color. |
| 140 | + |
| 141 | +<Example> |
| 142 | + <Progress striped percent={10} /> |
| 143 | + <Progress striped status="success" percent={25} /> |
| 144 | + <Progress striped status="info" percent={50} /> |
| 145 | + <Progress striped status="warning" percent={75} /> |
| 146 | + <Progress striped status="danger" percent={100} /> |
| 147 | +</Example> |
| 148 | + |
| 149 | +```TSX |
| 150 | +import { render, createCell, Fragment } from 'web-cell'; |
| 151 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 152 | + |
| 153 | +render( |
| 154 | + <Fragment> |
| 155 | + <Progress striped percent={10} /> |
| 156 | + <Progress striped status="success" percent={25} /> |
| 157 | + <Progress striped status="info" percent={50} /> |
| 158 | + <Progress striped status="warning" percent={75} /> |
| 159 | + <Progress striped status="danger" percent={100} /> |
| 160 | + </Fragment> |
| 161 | +); |
| 162 | +``` |
| 163 | + |
| 164 | +## Animated stripes |
| 165 | + |
| 166 | +The striped gradient can also be animated. |
| 167 | +Add `animated` property to `<Progress striped />` to animate the stripes right to left via CSS3 animations. |
| 168 | + |
| 169 | +<Example> |
| 170 | + <Progress striped animated percent={75} /> |
| 171 | +</Example> |
| 172 | + |
| 173 | +```TSX |
| 174 | +import { render, createCell } from 'web-cell'; |
| 175 | +import { Progress } from 'boot-cell/source/Reminder/Progress'; |
| 176 | + |
| 177 | +render(<Progress striped animated percent={75} />); |
| 178 | +``` |
0 commit comments