vue-progress-circle

January 18, 2025 ยท View on GitHub

npm version npm downloads npm downloads

vue version main language github stars

Circle progress bar component for vue3. See versions 1.X for vue2 component.

Live demo here

Global use

  • npm install in console
npm install --save vue-progress-circle
  • import component in your code
import { ProgressCircle } from 'vue-progress-circle'

you may also import it globally in your app

import { createApp } from "vue";
import vueProgressCircle from "vue-progress-circle";
createApp(App).use(vueProgressCircle);
  • Use components as described below

Components

Progress circle

<progress-circle completed-steps="5" total-steps="10"></progress-circle>
<progress-circle :diameter="cpDiameter"
                 :completed-steps="cpCompletedSteps"
                 :circle-color="cpCircleColor"
                 :start-color="cpStartColor"
                 :stop-color="cpStopColor"
                 :circle-width="cpCircleWidth"
                 :animation-duration="cpAnimationDuration"
                 :inner-color="cpInnerColor"
                 :inner-display="cpInnerDisplay"
                 :percent-color="cpPercentColor"
                 :circle-origin="cpCircleOrigin"
                 :reverse-rotation="cpReverseRotation"
                 :after-mount-delay="cpAfterMountDelay"
                 :total-steps="cpTotalSteps">
   <p>Total steps: {{ cpTotalSteps }}</p>
   <p>Completed steps: {{ cpCompletedSteps }}</p>
</progress-circle>
PropTypeNote
completed-stepsnumberREQUIRED: number of completed steps
total-stepsnumberREQUIRED: number of total steps
diameternumber(px) diameter of circle component (default 100)
circle-colorStringinner circle color (when no progress, default black)
start-colorStringleading color for progress bar (default red)
stop-colorStringtrailing color for progress bar (default blue)
inner-colorStringColor inside the circle (default transparent)
circle-widthnumber(px) circle width (default 10)
animation-durationnumber(ms) duration of animation when progress change (default 1000)
inner-displayStringChange inner circle filling. By default or 'slot', it will use provided slot (or nothing). 'Percent' will display progress percent rounded value
percent-colorStringChange color of progress percent if displayed (see inner-display, default inherit)
circle-originStringChange circle starting point. Accepted values are 'top', 'right', 'bottom', 'left' (default 'top')
reverse-rotationBooleanChange progress to clockwise rotation (default 'false')
after-mount-delaynumber(ms) duration to wait before displaying circle progress (default 0)

By default, this component provide a slot where you can insert any html code to be displayed inside the circle

You may use CSS variables for colors, and potentially override it easily using a class on the component. Declare component usage like

<progress-circle class="sample1"
    :completed-steps="5" :total-steps="10"
    start-color="var(--my-color)"
    stop-color="var(--my-color)">
</progress-circle>
<progress-circle class="sample2"
    :completed-steps="5" :total-steps="10"
    start-color="var(--my-color)"
    stop-color="var(--my-color)">
</progress-circle>

And then define CSS variables for each class

.sample1 {
  --my-color: fuchsia;
}
.sample2 {
  --my-color: green;
}

Each component will have it's own color!

Contribution

This library is managed with vue-CLI

  • Fork the repository
  • Run npm install
  • You can run npm run serve, the script will start the mini demo application
  • Do your stuff
  • When you're done, run npm run build command and commit your work for a pull request.