Files
webawesome/docs/components/progress-ring.md

75 lines
1.8 KiB
Markdown
Raw Normal View History

2020-07-15 17:30:37 -04: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-09-30 09:02:28 -04:00
<sl-progress-ring value="25"></sl-progress-ring>
2020-07-15 17:30:37 -04:00
```
## Examples
### Size
2021-09-30 08:40:21 -04:00
Use the `--size` custom property to set the diameter of the progress ring.
2020-07-15 17:30:37 -04:00
```html preview
2021-09-30 09:02:28 -04:00
<sl-progress-ring value="50" style="--size: 200px;"></sl-progress-ring>
2020-07-15 17:30:37 -04:00
```
2021-09-17 18:15:13 -04:00
### Track Width
2020-07-15 17:30:37 -04:00
2021-09-17 18:15:13 -04:00
Use the `track-width` attribute to set the width of the progress ring's track.
2020-07-15 17:30:37 -04:00
```html preview
2021-09-30 09:02:28 -04:00
<sl-progress-ring value="50" stroke-width="10"></sl-progress-ring>
2020-07-15 17:30:37 -04:00
```
### Colors
To change the color, use the `--track-color` and `--indicator-color` custom properties.
```html preview
<sl-progress-ring
2021-09-30 09:02:28 -04:00
value="50"
2021-08-18 08:55:59 -04:00
style="
2021-09-17 18:15:13 -04:00
--track-color: pink;
--indicator-color: deeppink;
2021-08-18 08:55:59 -04:00
"
2020-07-15 17:30:37 -04:00
></sl-progress-ring>
```
### Labels
Use the default slot to show a label.
```html preview
2021-09-30 09:02:28 -04:00
<sl-progress-ring value="50" class="progress-ring-labels" style="margin-bottom: .5rem;">50%</sl-progress-ring>
2020-07-15 17:30:37 -04:00
<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', () => {
2021-09-30 09:02:28 -04:00
const value = Math.min(100, progressRing.value + 10);
progressRing.value = value;
progressRing.textContent = `${value}%`;
2020-07-15 17:30:37 -04:00
});
subtractButton.addEventListener('click', () => {
2021-09-30 09:02:28 -04:00
const value = Math.max(0, progressRing.value - 10)
progressRing.value = value;
progressRing.textContent = `${value}%`;
2020-07-15 17:30:37 -04:00
});
</script>
```
[component-metadata:sl-progress-ring]