2020-07-15 21:30:37 +00:00
|
|
|
# Progress Ring
|
|
|
|
|
|
|
|
[component-header:sl-progress-ring]
|
|
|
|
|
|
|
|
Progress rings are used to show the progress of a determinate operation in a circular fashion.
|
|
|
|
|
|
|
|
```html preview
|
2021-06-18 12:51:00 +00:00
|
|
|
<sl-progress-ring percentage="25"></sl-progress-ring>
|
2020-07-15 21:30:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
### Size
|
|
|
|
|
|
|
|
Use the `size` attribute to set the diameter of the progress ring.
|
|
|
|
|
|
|
|
```html preview
|
|
|
|
<sl-progress-ring percentage="50" size="200"></sl-progress-ring>
|
|
|
|
```
|
|
|
|
|
2021-09-17 22:15:13 +00:00
|
|
|
### Track Width
|
2020-07-15 21:30:37 +00:00
|
|
|
|
2021-09-17 22:15:13 +00:00
|
|
|
Use the `track-width` attribute to set the width of the progress ring's track.
|
2020-07-15 21:30:37 +00:00
|
|
|
|
|
|
|
```html preview
|
|
|
|
<sl-progress-ring percentage="50" stroke-width="10"></sl-progress-ring>
|
|
|
|
```
|
|
|
|
|
|
|
|
### Colors
|
|
|
|
|
|
|
|
To change the color, use the `--track-color` and `--indicator-color` custom properties.
|
|
|
|
|
|
|
|
```html preview
|
|
|
|
<sl-progress-ring
|
|
|
|
percentage="50"
|
2021-08-18 12:55:59 +00:00
|
|
|
style="
|
2021-09-17 22:15:13 +00:00
|
|
|
--track-color: pink;
|
|
|
|
--indicator-color: deeppink;
|
2021-08-18 12:55:59 +00:00
|
|
|
"
|
2020-07-15 21:30:37 +00:00
|
|
|
></sl-progress-ring>
|
|
|
|
```
|
|
|
|
|
|
|
|
### Labels
|
|
|
|
|
|
|
|
Use the default slot to show a label.
|
|
|
|
|
|
|
|
```html preview
|
|
|
|
<sl-progress-ring percentage="50" size="200" class="progress-ring-labels" style="margin-bottom: .5rem;">50%</sl-progress-ring>
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
<sl-button circle><sl-icon name="dash"></sl-icon></sl-button>
|
|
|
|
<sl-button circle><sl-icon name="plus"></sl-icon></sl-button>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
const progressRing = document.querySelector('.progress-ring-labels');
|
|
|
|
const subtractButton = progressRing.nextElementSibling.nextElementSibling;
|
|
|
|
const addButton = subtractButton.nextElementSibling;
|
|
|
|
|
|
|
|
addButton.addEventListener('click', () => {
|
|
|
|
const percentage = Math.min(100, progressRing.percentage + 10);
|
|
|
|
progressRing.percentage = percentage;
|
|
|
|
progressRing.textContent = `${percentage}%`;
|
|
|
|
});
|
|
|
|
|
|
|
|
subtractButton.addEventListener('click', () => {
|
|
|
|
const percentage = Math.max(0, progressRing.percentage - 10)
|
|
|
|
progressRing.percentage = percentage;
|
|
|
|
progressRing.textContent = `${percentage}%`;
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
|
|
|
|
[component-metadata:sl-progress-ring]
|