emptyColor
Animatedtype | values | default |
---|---|---|
String | Object | any CSS color as String or Object to specify gradient | "#e6e9f0" |
Defines the color of the empty circle line. The property accepts any CSS color like #123
, rgba(230, 233, 240, 0.1)
or lime
or an Object to define gradients.
The general scheme to create the gradient is defined like follows:
:empty-color="{ colors [, radial ]}"
radial
(optional): Boolean, default isfalse
. Defines whether the gradient is radial or linear.colors
: Array of objects defining the gradient colors. Each object should have:color
: CSS color string (e.g.,"#6546f7"
)offset
: String representing the relative start/stop position in the gradient (e.g.,"10"
). It should be a number between 0 and 100.opacity
(optional): Number representing the opacity (e.g.,1
)
Usage 📜
vue
<ve-progress empty-color="#3f79ff" />
<ve-progress empty-color="lime" />
<ve-progress empty-color="rgba(230, 233, 240, 0.1)" />
<ve-progress
:empty-color="{
radial: false,
colors: [
{ color: '#6546f7', offset: '0', opacity: 1 },
{ color: 'lime', offset: '100', opacity: 0.6 },
],
}"
/>
SVG Gradient
The coloring concept is based on the SVG specification. Only offset and opacity are supported for now. In the future releases, more advanced gradient features will be added
Examples
Define the color as string is straightforward.
vue
<template>
<ve-progress empty-color="DimGray" :progress="50" />
<ve-progress empty-color="#1ABC9C" :progress="50" />
<ve-progress empty-color="rgba(255, 87, 51, 0.7)" :progress="50" />
<ve-progress :color="color4" :progress="50" />
</template>
<script setup lang="ts">
import randomColor from "randomcolor";
import { onMounted, ref } from "vue";
const color4 = ref(randomColor());
onMounted(() => {
setInterval(() => {
color4.value = randomColor();
}, 1000);
});
</script>
The examples below demonstrate how gradient colors can be defined.
vue
<template>
<ve-progress
:empty-color="gradient1"
empty-thickness="10%"
:progress="50"
:size="160"
/>
<ve-progress
:empty-color="gradient2"
empty-thickness="10%"
:progress="50"
:size="160"
/>
<ve-progress
:empty-color="gradient3"
empty-thickness="30%"
:progress="50"
:size="160"
/>
<ve-progress
:empty-color="gradient4"
empty-thickness="30%"
:progress="50"
:size="160"
/>
</template>
<script lang="ts">
import randomColor from "randomcolor";
import { Gradient } from "../../types";
export const gradient1 = {
colors: [
{
color: "#3498DB",
offset: "0",
},
{
color: "#8A2BE2",
offset: "100",
},
],
};
export const gradient2 = {
colors: [
{
color: "#3498DB",
offset: "0",
},
{
color: "rgb(72, 201, 176)",
offset: "25",
},
{
color: "hsl(48, 89%, 60%, 0.2)",
offset: "50",
},
{
color: "Crimson",
offset: "75",
},
{
color: "#8A2BE2",
offset: "100",
},
],
};
export const gradient3 = {
radial: true,
colors: [
{
color: "#3498DB",
offset: "0",
opacity: 0.5,
},
{
color: "rgb(72, 201, 176)",
offset: "25",
},
{
color: "hsl(48, 89%, 60%, 0.2)",
offset: "50",
},
{
color: "Crimson",
offset: "75",
},
{
color: "#8A2BE2",
offset: "100",
},
],
};
export const gradient4 = {
colors: [
{
color: "#3498DB",
offset: "0",
},
{
color: "hsl(48, 89%, 60%, 0.2)",
offset: "50",
},
{
color: "#8A2BE2",
offset: "100",
},
],
};
export const randomizeGradient = (gradient: Gradient) => {
gradient.colors = gradient.colors.map((conf) => ({
...conf,
color: randomColor(),
}));
return gradient;
};
export default {
setup() {
return { gradient1, gradient2, gradient3, gradient4 };
},
onMounted() {
setInterval(() => {
randomizeGradient(gradient4);
}, 1000);
},
};
</script>
The gradients give a lot of room for experimentation and you can achieve a lot of exciting effects with colors alone. The following examples give some inspiration:
vue
<template>
<ve-progress v-for="(c, i) in circles" v-bind="c" :progress="50" :key="i" />
</template>
<script lang="ts">
export const circle1 = {
emptyThickness: 40,
thickness: 5,
emptyColor: {
radial: true,
colors: [
{
color: "#3260FC",
offset: "50",
opacity: "0.15",
},
{
color: "#3260FC",
offset: "70",
opacity: "0.15",
},
{
color: "#3260FC",
offset: "70",
opacity: "0.1",
},
{
color: "#3260FC",
offset: "90",
opacity: "1",
},
{
color: "#3260FC",
offset: "60",
opacity: "1",
},
{
color: "#3260FC",
offset: "0",
opacity: "0",
},
],
},
};
export const circle2 = {
line: "butt",
lineMode: "in-over",
emptyThickness: "100",
thickness: "2",
emptyColor: {
radial: true,
colors: [
{
color: "#3260FC",
offset: "49",
opacity: 1,
},
{
color: "black",
offset: "50",
opacity: 0,
},
{
color: "black",
offset: "90",
opacity: 0,
},
{
color: "#3260FC",
offset: "95",
opacity: 1,
},
{
color: "#3260FC",
offset: "100",
opacity: 0.2,
},
],
},
};
export const circle3 = {
thickness: 2,
emptyThickness: 20,
line: "round",
lineMode: "out-over",
emptyColor: {
radial: true,
colors: [
{
color: "#3260FC",
offset: "49",
opacity: 1,
},
{
color: "#3260FC",
offset: "80",
opacity: 1,
},
{
color: "#3260FC",
offset: "100",
opacity: 0,
},
],
},
};
export const circle4 = {
thickness: 10,
emptyThickness: 20,
line: "round",
lineMode: "out-over",
emptyColor: {
radial: true,
colors: [
{
color: "#3260FC",
offset: "89",
opacity: 0,
},
{
color: "#3260FC",
offset: "91",
opacity: 1,
},
{
color: "#3260FC",
offset: "93",
opacity: 0,
},
{
color: "#3260FC",
offset: "95",
opacity: 1,
},
{
color: "#3260FC",
offset: "97",
opacity: 0,
},
{
color: "#3260FC",
offset: "99",
opacity: 1,
},
{
color: "#3260FC",
offset: "100",
opacity: 0,
},
],
},
};
export const circle5 = {
line: "round",
lineMode: "out",
thickness: 5,
emptyThickness: 20,
emptyColor: {
radial: true,
colors: [
{
color: "#3260FC",
offset: "88",
opacity: 0,
},
{
color: "#D4AC0D",
offset: "90",
opacity: 0,
},
{
color: "#27AE60",
offset: "93",
opacity: 1,
},
{
color: "#E74C3C",
offset: "96",
opacity: 1,
},
{
color: "#3260FC",
offset: "99",
opacity: 1,
},
{
color: "#3260FC",
offset: "100",
opacity: 0,
},
],
},
};
export const circle6 = {
line: "butt",
thickness: 4,
emptyThickness: 100,
color: "red",
emptyColor: {
radial: true,
colors: [
{
color: "#8A2BE2",
offset: "0",
opacity: 0.5,
},
{
color: "#8A2BE2",
offset: "98",
opacity: 0.5,
},
{
color: "#3260FC",
offset: "99",
opacity: 1,
},
{
color: "#3260FC",
offset: "100",
opacity: 1,
},
],
},
};
export default {
setup() {
return {
circles: [circle1, circle2, circle3, circle4, circle5, circle6],
};
},
};
</script>