Skip to main content

Progress Bar

<gstock-progress-bar> | GstockProgressBar

Showing Values

Use the default slot to show a value.

70%
<div class="progress-bar-values">
  <gstock-progress-bar value="70">
    70%
  </gstock-progress-bar>

  <br />

  <gstock-icon-button icon="minus" variant="outlined" size="small"></gstock-icon-button>
  <gstock-icon-button icon="plus" variant="outlined" size="small"></gstock-icon-button>
</div>

<script type="module">
  (() => {
    const container = document.querySelector('.progress-bar-values');
    const progressBar = container.querySelector('gstock-progress-bar');
    const subtractButton = container.querySelector('gstock-icon-button[icon=minus]');
    const addButton = container.querySelector('gstock-icon-button[icon=plus]');

    subtractButton.addEventListener('click', () => {
      const value = Math.max(0, progressBar.value - 10);
      progressBar.value = value;
      progressBar.textContent = `${value}%`;
      subtractButton.disabled = value === 0;
      addButton.disabled = value === 100;
    });

    addButton.addEventListener('click', () => {
      const value = Math.min(100, progressBar.value + 10);
      progressBar.value = value;
      progressBar.textContent = `${value}%`;
      addButton.disabled = value === 100;
      subtractButton.disabled = value === 0;
    });
  })();
</script>

Indeterminate

Use the indeterminate attribute to to animate the progress bar indeterminately. In this state, value is ignored and the label, if present, will not be shown.

<gstock-progress-bar indeterminate></gstock-progress-bar>

Labels

Use the label attribute to label the progress bar and tell assistive devices how to announce it.

<gstock-progress-bar value="50" label="Upload progress"></gstock-progress-bar>

Custom Height

Use the --height custom property to set the height of progress bar.

<gstock-progress-bar value="50" style="--height: 25px;"></gstock-progress-bar>