AK Progress
ak-ui/progressFreeComponent
Accessible horizontal progress and octagonal gauge adapters with clamped values.
Install it
npx shadcn@latest add https://ak-ui.yunyoujun.cn/r/progress.jsonSource
1<script setup lang="ts">2import { computed } from 'vue'3import type { CSSProperties } from 'vue'4import type { AkProgressVariant } from './types'56import '@yunyoujun/ak-ui'78const props = withDefaults(defineProps<{9 label?: string10 max?: number11 min?: number12 value?: number13 valueLabel?: string14 variant?: AkProgressVariant15}>(), {16 label: 'Progress',17 max: 100,18 min: 0,19 value: 0,20 valueLabel: '',21 variant: 'default',22})2324const normalizedValue = computed(() => Math.min(props.max, Math.max(props.min, props.value)))25const percentage = computed(() => {26 const range = props.max - props.min27 return range > 0 ? ((normalizedValue.value - props.min) / range) * 100 : 028})29const progressStyle = computed(() => ({30 '--ak-progress-value': `${percentage.value}%`,31}) as CSSProperties)32</script>3334<template>35 <div36 class="ak-progress"37 data-slot="ak-progress"38 role="progressbar"39 :aria-label="label"40 :aria-valuemax="max"41 :aria-valuemin="min"42 :aria-valuenow="normalizedValue"43 :class="variant !== 'default' && `ak-progress--${variant}`"44 :data-variant="variant"45 :style="progressStyle"46 >47 <div class="ak-progress__header">48 <span><slot name="label">{{ label }}</slot></span>49 <span class="ak-progress__value"><slot name="value">{{ valueLabel || `${Math.round(percentage)}%` }}</slot></span>50 </div>51 <div class="ak-progress__track"><span class="ak-progress__fill" /></div>52 </div>53</template>
What it pulls in
npm packages
Files it writes
More from ak-ui
All 7 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AK Buttonbutton | ak-ui | Components | Free | 1 dep · 3 files | |
| AK Cardcard | ak-ui | Components | Free | 1 dep · 8 files | |
| AK Input Numberinput-number | ak-ui | Components | Free | 1 dep · 2 files | |
| AK Noticenotice | ak-ui | Components | Free | 1 dep · 3 files | |
| AK Statusstatus | ak-ui | Components | Free | 1 dep · 4 files | |
| AK Tabstabs | ak-ui | Components | Free | 1 dep · 4 files |
