Circle
introduce
A circular progress bar component that supports progress gradient animation.
Code Demo
Basic usage
The rate
attribute represents the target progress of the progress bar, and v-model:current-rate
represents the real-time progress during the animation. When rate
changes, v-model:current-rate
will change at speed
until it reaches the value set by rate
.
<z-circle
v-model:current-rate="currentRate1"
:rate="rate"
:speed="100"
:text="currentRate1.toFixed(0) + '%'"
/>
import { ref } from 'vue'
const rate = ref(70)
const currentRate1 = ref(0)
Width customization
Control the width of the progress bar through the stroke-width
property.
<z-circle
v-model:current-rate="currentRate3"
:rate="rate"
:speed="100"
:stroke-width="10"
text="Customized width"
/>
Color customization
Use the color
property to control the progress bar color, and the layer-color
property to control the track color.
<z-circle
v-model:current-rate="currentRate3"
color="#ee0a24"
:rate="rate"
layer-color="#ebedf0"
:speed="100"
text="Color customization"
/>
Gradient color
The color
property supports passing in an object format to define gradient colors.
<z-circle
v-model:current-rate="currentRate"
:rate="rate"
:speed="100"
:color="gradientColor"
text="gradient color"
/>
const gradientColor = {
'0%': '#3fecff',
'100%': '#6149f6'
}
Counterclockwise
Set clockwise
to false
and progress will start in a counter-clockwise direction.
<z-circle
v-model:current-rate="currentRate4"
color="#07c160"
:rate="rate"
:speed="100"
:clockwise="false"
text="Counterclockwise"
/>
Size customization
Set the ring diameter via the size
property.
<z-circle
v-model:current-rate="currentRate4"
color="#7232dd"
:rate="rate"
:speed="100"
:size="140"
text="Customized size"
/>
starting point
The progress bar starts from the top by default, and the starting position can be set through the start-position
property.
<z-circle
v-model:current-rate="currentRate"
:rate="rate"
text="left"
start-position="left"
/>
<z-circle
v-model:current-rate="currentRate"
:rate="rate"
text="right"
start-position="right"
/>
<z-circle
v-model:current-rate="currentRate"
:rate="rate"
text="bottom"
start-position="bottom"
/>
API
Props
Parameters | Description | Type | Default value |
---|---|---|---|
v-model:current-rate | Current progress | number | - |
rate | target progress | number | string | 100 |
size | Ring diameter, default unit is px | number | string | 100px |
color | Progress bar color, passing in object format can define gradient color | string | object | #1989fa |
layer-color | track color | string | white |
fill | fill color | string | none |
speed | Animation speed (unit: rate/s) | number | string | 0 |
text | text | string | - |
stroke-width | progress bar width | number | string | 40 |
stroke-linecap | The shape of the endpoint of the progress bar, optional values are square butt | string | round |
clockwise | Whether to increase clockwise | boolean | true |
start-position | Progress starting position, optional values are left , right , bottom | CircleStartPosition | top |
Slots
Name | Description |
---|---|
default | Custom text content |
Theme customization
Style variables
The component provides the following CSS variables, which can be used to customize styles. For usage, please refer to ConfigProvider component.
Name | Default | Description |
---|---|---|
--z-circle-size | 200rpx | - |
--z-circle-color | var(--z-primary-color) | - |
--z-circle-layer-color | var(--z-white) | - |
--z-circle-text-color | var(--z-text-color) | - |
--z-circle-text-font-weight | var(--z-font-bold) | - |
--z-circle-text-font-size | var(--z-font-size-md) | - |
--z-circle-text-line-height | var(--z-line-height-md) | - |