2016-11-10 21:46:55 +08:00
## Progress
Progress is used to show the progress of current operation, and inform the user the current status.
2019-05-28 11:02:00 +08:00
### Linear progress bar
2016-11-10 21:46:55 +08:00
2019-05-28 11:02:00 +08:00
:::demo Use `percentage` attribute to set the percentage. It's **required** and must be between `0-100` . You can custom text format by setting `format` .
2016-11-10 21:46:55 +08:00
```html
2019-05-28 11:02:00 +08:00
< el-progress :percentage = "50" > < / el-progress >
< el-progress :percentage = "100" :format = "format" > < / el-progress >
2016-11-10 21:46:55 +08:00
< el-progress :percentage = "100" status = "success" > < / el-progress >
2019-05-28 11:02:00 +08:00
< el-progress :percentage = "100" status = "warning" > < / el-progress >
2016-11-10 21:46:55 +08:00
< el-progress :percentage = "50" status = "exception" > < / el-progress >
2019-05-28 11:02:00 +08:00
< script >
export default {
methods: {
format(percentage) {
return percentage === 100 ? 'Full' : `${percentage}%` ;
}
}
};
< / script >
2016-11-10 21:46:55 +08:00
```
:::
2019-05-28 11:02:00 +08:00
### Internal percentage
2016-11-10 21:46:55 +08:00
In this case the percentage takes no additional space.
:::demo `stroke-width` attribute decides the `width` of progress bar, and use `text-inside` attribute to put description inside the progress bar.
```html
2019-05-28 11:02:00 +08:00
< el-progress :text-inside = "true" :stroke-width = "26" :percentage = "70" > < / el-progress >
< el-progress :text-inside = "true" :stroke-width = "24" :percentage = "100" status = "success" > < / el-progress >
< el-progress :text-inside = "true" :stroke-width = "22" :percentage = "80" status = "warning" > < / el-progress >
< el-progress :text-inside = "true" :stroke-width = "20" :percentage = "50" status = "exception" > < / el-progress >
```
:::
### Custom color
You can use `color` attr to set the progress bar color. it accepts color string, function, or array.
:::demo
```html
< el-progress :percentage = "percentage" :color = "customColor" > < / el-progress >
< el-progress :percentage = "percentage" :color = "customColorMethod" > < / el-progress >
< el-progress :percentage = "percentage" :color = "customColors" > < / el-progress >
< div >
< el-button-group >
< el-button icon = "el-icon-minus" @click =" decrease " ></ el-button >
< el-button icon = "el-icon-plus" @click =" increase " ></ el-button >
< / el-button-group >
< / div >
< script >
export default {
data() {
return {
percentage: 20,
customColor: '#409eff',
customColors: [
{color: '#f56c6c', percentage: 20},
{color: '#e6a23c', percentage: 40},
{color: '#5cb87a', percentage: 60},
{color: '#1989fa', percentage: 80},
{color: '#6f7ad3', percentage: 100}
]
};
},
methods: {
customColorMethod(percentage) {
if (percentage < 30 ) {
return '#909399';
} else if (percentage < 70 ) {
return '#e6a23c';
} else {
return '#67c23a';
}
},
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0 ) {
this.percentage = 0;
}
}
}
}
< / script >
2016-11-10 21:46:55 +08:00
```
:::
### Circular progress bar
:::demo You can specify `type` attribute to `circle` to use circular progress bar, and use `width` attribute to change the size of circle.
```html
< el-progress type = "circle" :percentage = "0" > < / el-progress >
< el-progress type = "circle" :percentage = "25" > < / el-progress >
< el-progress type = "circle" :percentage = "100" status = "success" > < / el-progress >
2019-05-28 11:02:00 +08:00
< el-progress type = "circle" :percentage = "70" status = "warning" > < / el-progress >
2016-11-10 21:46:55 +08:00
< el-progress type = "circle" :percentage = "50" status = "exception" > < / el-progress >
2019-05-28 11:02:00 +08:00
```
:::
### Dashboard progress bar
You also can specify `type` attribute to `dashboard` to use dashboard progress bar.
:::demo
```html
< el-progress type = "dashboard" :percentage = "percentage" :color = "colors" > < / el-progress >
< div >
< el-button-group >
< el-button icon = "el-icon-minus" @click =" decrease " ></ el-button >
< el-button icon = "el-icon-plus" @click =" increase " ></ el-button >
< / el-button-group >
< / div >
< script >
export default {
data() {
return {
percentage: 10,
colors: [
{color: '#f56c6c', percentage: 20},
{color: '#e6a23c', percentage: 40},
{color: '#5cb87a', percentage: 60},
{color: '#1989fa', percentage: 80},
{color: '#6f7ad3', percentage: 100}
]
};
},
methods: {
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0 ) {
this.percentage = 0;
}
}
}
}
< / script >
```
2016-11-10 21:46:55 +08:00
:::
### Attributes
| Attribute | Description | Type | Accepted Values | Default |
| --- | ---- | ---- | ---- | ---- |
| **percentage** | percentage, **required** | number | 0-100 | 0 |
2019-05-28 11:02:00 +08:00
| type | the type of progress bar | string | line/circle/dashboard | line |
2016-11-10 21:46:55 +08:00
| stroke-width | the width of progress bar | number | — | 6 |
| text-inside | whether to place the percentage inside progress bar, only works when `type` is 'line' | boolean | — | false |
2019-05-28 11:02:00 +08:00
| status | the current status of progress bar | string | success/exception/warning | — |
| color | background color of progress bar. Overrides `status` prop | string/function/array | — | '' |
2016-11-10 21:46:55 +08:00
| width | the canvas width of circle progress bar | number | — | 126 |
| show-text | whether to show percentage | boolean | — | true |