Progress Bar
The Progress Bar component visually represents the progress of a task or process, allowing users to track completion at a glance. It supports different sizes and an optional label for enhanced clarity.
Basic Usage
<template>
<mc-progress-bar :value="progressValue" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(25);
</script>Size
<template>
<mc-progress-bar :value="50" size="xs" />
<mc-progress-bar :value="75" size="sm" />
<mc-progress-bar :value="100" size="lg" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(25);
</script>Label
<template>
<mc-progress-bar :value="100" size="lg" :label="true" />
<mc-progress-bar :value="100" size="lg" :label="false" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(25);
</script>Supporting Label
The supporting-label prop displays additional text alongside the percentage label. This is useful for providing context, such as the total value or unit of measurement.
<template>
<!-- Display progress with total value -->
<mc-progress-bar :value="60" :max="100" :label="true" supporting-label="of 100 MB" />
<!-- Display with status text -->
<mc-progress-bar :value="75" :label="true" supporting-label="Complete" />
<!-- Display with contextual information -->
<mc-progress-bar :value="45" :label="true" supporting-label="Remaining" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(60);
</script>Placements
The label-placement prop controls where the percentage label appears relative to the progress bar. When the label prop is set to true, you can position the percentage label in various alignments.
Top Placements
<template>
<mc-progress-bar :value="60" label-placement="top-start" :label="true" />
<mc-progress-bar :value="60" label-placement="top-center" :label="true" />
<mc-progress-bar :value="60" label-placement="top-end" :label="true" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(60);
</script>Bottom Placements
<template>
<mc-progress-bar :value="60" label-placement="bottom-start" :label="true" />
<mc-progress-bar :value="60" label-placement="bottom-center" :label="true" />
<mc-progress-bar :value="60" label-placement="bottom-end" :label="true" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(60);
</script>Side Placements
<template>
<mc-progress-bar :value="60" label-placement="left" :label="true" />
<mc-progress-bar :value="60" label-placement="right" :label="true" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(60);
</script>Color Variants
The Progress Bar component supports different color variants to indicate different states or contexts.
<template>
<!-- Success (default) -->
<mc-progress-bar :value="75" color="success" />
<!-- Danger/Error state -->
<mc-progress-bar :value="60" color="danger" />
<!-- Warning state -->
<mc-progress-bar :value="45" color="warning" />
<!-- Info state -->
<mc-progress-bar :value="30" color="info" />
<!-- Neutral state -->
<mc-progress-bar :value="90" color="neutral" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(25);
</script>Custom Max Values
You can customize the maximum value to represent different scales or contexts.
<template>
<!-- 5 out of 10 = 50% -->
<mc-progress-bar :value="5" :max="10" :label="true" />
<!-- 3 out of 12 = 25% -->
<mc-progress-bar :value="3" :max="12" :label="true" />
<!-- 8 out of 20 = 40% -->
<mc-progress-bar :value="8" :max="20" :label="true" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(25);
</script>Percentage Placement
Control where the percentage label appears relative to the progress bar. You can position it at the top, bottom, left, or right.
<template>
<!-- Percentage above the progress bar -->
<mc-progress-bar :value="60" labelPlacement="top" :label="true" />
<!-- Percentage below the progress bar (default) -->
<mc-progress-bar :value="60" labelPlacement="bottom" :label="true" />
<!-- Percentage to the left of the progress bar -->
<mc-progress-bar :value="60" labelPlacement="left" :label="true" />
<!-- Percentage to the right of the progress bar -->
<mc-progress-bar :value="60" labelPlacement="right" :label="true" />
</template>
<script setup>
import { ref } from 'vue';
const progressValue = ref(25);
</script>Advanced Examples
File Upload Progress
<template>
<div>
<mc-progress-bar :value="uploadProgress" color="success" size="sm" :label="true" />
</div>
</template>
<script setup>
import { ref } from 'vue';
const uploadProgress = ref(65);
// Simulate upload progress
const simulateUpload = () => {
const interval = setInterval(() => {
uploadProgress.value += Math.random() * 10;
if (uploadProgress.value >= 100) {
uploadProgress.value = 100;
clearInterval(interval);
}
}, 500);
};
// Start simulation
simulateUpload();
</script>Error State Progress
<template>
<div>
<mc-progress-bar :value="errorProgress" color="danger" size="lg" :label="true" />
<p class="mc-text-color-danger-base mc-text-sm">Upload failed at 60%</p>
</div>
</template>
<script setup>
import { ref } from 'vue';
const errorProgress = ref(60);
</script>Multi-Step Process
Step 3 of 5 completed
<template>
<div>
<mc-progress-bar :value="stepProgress" color="info" size="sm" :label="true" />
<p class="mc-text-color-base mc-text-sm">Step {{ currentStep }} of {{ totalSteps }} completed</p>
</div>
</template>
<script setup>
import { ref } from 'vue';
const currentStep = ref(3);
const totalSteps = ref(5);
const stepProgress = ref(60); // 3/5 = 60%
</script>API Reference
Props
| Name | Description | Type | Default |
|---|---|---|---|
value | The current progress value. This determines how much of the progress bar is filled. The value is calculated as a percentage of the max value. | number | 0 |
size | Defines the height of the progress bar. Options include:
| 'xs' | 'sm' | 'lg' | 'lg' |
max | The maximum value for the progress bar. The value prop is calculated as a percentage of this number. Must be between 1 and 100. | number | 100 |
label | When set to true, displays a percentage label below the progress bar. The label shows the calculated percentage based on value and max. | boolean | true |
color | Defines the color theme of the progress bar. Options include:
| 'success' | 'danger' | 'warning' | 'info' | 'neutral' | 'success' |
label-placement | Defines the position and alignment of the percentage label relative to the progress bar. Options include:
| 'top' | 'top-start' | 'top-center' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-center' | 'bottom-end' | 'left' | 'right' | 'bottom' |
supporting-label | Displays additional text alongside the percentage label. This is useful for providing context such as the total value, unit of measurement, or status information. The supporting label appears next to the main percentage label. | string | '' |