DsMeter component displays a numeric value as a graphical meter within a defined range. This component is useful for showing progress, usage statistics, capacity levels, or any metric that has minimum and maximum bounds.
Component Location
Basic Usage
Component API
DsMeter
The root component that manages meter state and provides context to child components.| Prop | Type | Default | Description |
|---|---|---|---|
value | number | Required | Current value of the meter |
min | number | 0 | Minimum value |
max | number | 100 | Maximum value |
locale | string | 'en-US' | Locale for number formatting |
format | Intl.NumberFormatOptions | - | Custom formatting options |
getAriaValueText | (value: number, min: number, max: number) => string | - | Custom aria-valuetext generator |
class | string | - | Additional CSS classes |
DsMeterTrack
Container for the meter indicator that represents the full range.| Prop | Type | Default | Description |
|---|---|---|---|
class | string | - | Additional CSS classes |
h-4 w-full overflow-hidden rounded-full bg-secondary
DsMeterIndicator
Visual indicator that shows the current value position within the range.| Prop | Type | Default | Description |
|---|---|---|---|
class | string | - | Additional CSS classes |
DsMeterLabel
Accessible label for the meter that connects to the root viaaria-labelledby.
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | Auto-generated | Optional ID for the label |
class | string | - | Additional CSS classes |
DsMeterValue
Displays the formatted value, hidden from screen readers since the value is announced via ARIA.| Prop | Type | Default | Description |
|---|---|---|---|
class | string | - | Additional CSS classes |
formattedValue(string): Formatted value stringvalue(number): Raw numeric value
Usage Examples
Without Label and Value
Minimal meter showing only the visual indicator:With Custom Formatting
Display a currency value:With Custom Value Display
Use scoped slots to customize the value display:Percentage Display
By default, values are treated as percentages (0-100 range):Custom Range Display
For non-percentage ranges:Localized Formatting
Format numbers according to different locales:Styling
Custom Colors
Change indicator color using Tailwind classes:Different Sizes
Adjust the meter height:Custom Layout
Arrange label and value horizontally:Accessibility
The meter component includes proper accessibility features:- Role:
role="meter"on the root element - ARIA Attributes:
aria-valuenow: Current valuearia-valuemin: Minimum valuearia-valuemax: Maximum valuearia-valuetext: Human-readable valuearia-labelledby: Links to the label element
- Screen Reader Support: The value display has
aria-hidden="true"since the value is announced via ARIA attributes
Custom Accessibility Text
Provide custom ARIA text for screen readers:Common Use Cases
Progress Tracking
Resource Usage
Quota Display
Architecture Notes
- Context-Based State: The root component provides context to child components using Vue’s
provide/inject - Automatic Calculation: The indicator width is calculated automatically based on value, min, and max
- Type-Safe: All components have proper TypeScript interfaces
- Composable: Build custom layouts by arranging components differently
- Formatting: Uses
Intl.NumberFormatfor locale-aware number formatting
Related Documentation
- UI Design System - Overall design patterns
- Custom UI Components - Component development guide

