Skip to content

Instantly share code, notes, and snippets.

@leemartin
Created March 24, 2024 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemartin/d314b14f1817fd8075f49b98f613db08 to your computer and use it in GitHub Desktop.
Save leemartin/d314b14f1817fd8075f49b98f613db08 to your computer and use it in GitHub Desktop.
A progress circle Vue component powered by CSS conic gradient
<template>
<div class="h-full rounded-full w-full" :style="conicGradient"></div>
</template>
<script setup>
// Props
const props = defineProps({
color: {
type: String,
default: '#000000'
},
progress: {
type: Number,
default: 0.5
},
width: {
type: Number,
default: 3.8
}
})
// Conic gradient
// ----------
const conicGradient = computed(() => {
return {
background: `conic-gradient(${props.color} 0deg, ${props.color} ${props.progress * 360}deg, transparent ${props.progress * 360}deg)`,
maskImage: `radial-gradient(transparent ${71 - props.width}%, white ${71 - props.width}%)`
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment