Keyboard shortcut: Ctrl + K
Get started

Meter group

VMeterGroup shows how a total breaks down: several readings sharing one range, drawn as the parts of a single bar with a legend.

Usage

vue
Storage67%
  • Documents 25%
  • Photos 19%
  • Apps 14%
  • System 9%
<script setup lang="ts">
import { VMeterGroup, type MeterGroupItem } from 'vectis-ui'

const ITEMS: MeterGroupItem[] = [
  { label: 'Documents', value: 32 },
  { label: 'Photos', value: 24 },
  { label: 'Apps', value: 18 },
  { label: 'System', value: 12, tone: 'neutral' },
]
</script>

<template>
  <VMeterGroup class="group" :items="ITEMS" :max="128" label="Storage" show-value />
</template>

<style scoped>
.group {
  max-inline-size: 24rem;
}
</style>

Examples

Colours

Each item takes a tone or a color. Without either, its hue is derived from its position, starting from the accent, and follows the theme. An icon replaces the legend swatch.

vue
Budget
  • Rent 40%
  • Food 20%
  • Transport 10%
  • Savings 15%
  • Leisure 8%
<script setup lang="ts">
import { VMeterGroup, type MeterGroupItem } from 'vectis-ui'

const ITEMS: MeterGroupItem[] = [
  { label: 'Rent', value: 40, icon: 'home' },
  { label: 'Food', value: 20 },
  { label: 'Transport', value: 10 },
  { label: 'Savings', value: 15, tone: 'success' },
  { label: 'Leisure', value: 8, color: '#db2777' },
]
</script>

<template>
  <VMeterGroup class="group" :items="ITEMS" label="Budget" />
</template>

<style scoped>
.group {
  max-inline-size: 24rem;
}
</style>

Values

showValue writes the sum after the label. The sum and every amount are percentages of max by default; formatOptions formats them for the current locale, and valueText replaces the sum.

vue
Storage86 GB of 128 GB
  • Documents 32 GB
  • Photos 24 GB
  • Apps 18 GB
  • System 12 GB
<script setup lang="ts">
import { VMeterGroup, type MeterGroupItem } from 'vectis-ui'

const ITEMS: MeterGroupItem[] = [
  { label: 'Documents', value: 32 },
  { label: 'Photos', value: 24 },
  { label: 'Apps', value: 18 },
  { label: 'System', value: 12, tone: 'neutral' },
]
</script>

<template>
  <VMeterGroup
    class="group"
    :items="ITEMS"
    :max="128"
    label="Storage"
    :format-options="{ style: 'unit', unit: 'gigabyte' }"
    value-text="86 GB of 128 GB"
    show-value
  />
</template>

<style scoped>
.group {
  max-inline-size: 24rem;
}
</style>

Overflow

When the amounts add up to more than max, the parts share the whole bar in proportion. The legend keeps their real amounts.

vue
Over the quota100%
  • Documents 50%
  • Photos 38%
  • Apps 28%
  • System 19%
<script setup lang="ts">
import { VMeterGroup, type MeterGroupItem } from 'vectis-ui'

const ITEMS: MeterGroupItem[] = [
  { label: 'Documents', value: 32 },
  { label: 'Photos', value: 24 },
  { label: 'Apps', value: 18 },
  { label: 'System', value: 12, tone: 'neutral' },
]
</script>

<template>
  <VMeterGroup class="group" :items="ITEMS" :max="64" label="Over the quota" show-value />
</template>

<style scoped>
.group {
  max-inline-size: 24rem;
}
</style>

Slots

The value slot replaces the sum. item-leading, item-label and item-value replace a legend row’s swatch, label and amount.

vue
Storage42 GB free
  • Documents 32 GB
  • Photos 24 GB
  • Apps 18 GB
  • System 12 GB
<script setup lang="ts">
import { VMeterGroup, type MeterGroupItem } from 'vectis-ui'

const ITEMS: MeterGroupItem[] = [
  { label: 'Documents', value: 32 },
  { label: 'Photos', value: 24 },
  { label: 'Apps', value: 18 },
  { label: 'System', value: 12, tone: 'neutral' },
]
</script>

<template>
  <VMeterGroup class="group" :items="ITEMS" :max="128" label="Storage" show-value>
    <template #value="{ value, max }">{{ max - value }} GB free</template>
    <template #item-value="{ item }">{{ item.value }} GB</template>
  </VMeterGroup>
</template>

<style scoped>
.group {
  max-inline-size: 24rem;
}
</style>

Sizes

size sets the thickness of the bar, from 2 to 20 pixels, on the same scale as VMeter. hideLegend hides the legend visually; screen readers still read it.

vue
xs
  • Documents 25%
  • Photos 19%
  • Apps 14%
  • System 9%
sm
  • Documents 25%
  • Photos 19%
  • Apps 14%
  • System 9%
md
  • Documents 25%
  • Photos 19%
  • Apps 14%
  • System 9%
lg
  • Documents 25%
  • Photos 19%
  • Apps 14%
  • System 9%
xl
  • Documents 25%
  • Photos 19%
  • Apps 14%
  • System 9%
<script setup lang="ts">
import { VMeterGroup, type MeterGroupItem, type MeterGroupSize } from 'vectis-ui'

const ITEMS: MeterGroupItem[] = [
  { label: 'Documents', value: 32 },
  { label: 'Photos', value: 24 },
  { label: 'Apps', value: 18 },
  { label: 'System', value: 12, tone: 'neutral' },
]

const SIZES: MeterGroupSize[] = ['xs', 'sm', 'md', 'lg', 'xl']
</script>

<template>
  <div class="column">
    <VMeterGroup
      v-for="size in SIZES"
      :key="size"
      :items="ITEMS"
      :max="128"
      :size="size"
      :label="size"
      hide-legend
    />
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
  max-inline-size: 24rem;
}
</style>

Orientation

orientation="vertical" fills from the bottom up and puts the legend beside the bar. Set a height to control the bar’s length.

vue
Storage67%
  • Documents 25%
  • Photos 19%
  • Apps 14%
  • System 9%
<script setup lang="ts">
import { VMeterGroup, type MeterGroupItem } from 'vectis-ui'

const ITEMS: MeterGroupItem[] = [
  { label: 'Documents', value: 32 },
  { label: 'Photos', value: 24 },
  { label: 'Apps', value: 18 },
  { label: 'System', value: 12, tone: 'neutral' },
]
</script>

<template>
  <VMeterGroup
    :items="ITEMS"
    :max="128"
    label="Storage"
    orientation="vertical"
    size="lg"
    show-value
  />
</template>

API

Props

PropTypeDefault
itemsMeterGroupItem[][]
Parts, in the order they fill the bar.
maxnumber100
Total the amounts are measured against. Parts share the bar in proportion when they exceed it.
labelstringnone
What is measured, shown above the bar and naming the group. Uses the dictionary by default; ARIA naming attributes take precedence.
hideLabelbooleanfalse
Hides the label visually. Screen readers still read it.
showValuebooleanfalse
Writes the sum of the amounts after the label.
valueTextstringnone
Text replacing the formatted sum.
formatOptionsIntl.NumberFormatOptionsnone
Intl.NumberFormat options formatting the sum and every amount.
hideLegendbooleanfalse
Hides the legend visually. Screen readers still read it.
sizeMeterGroupSize'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
Bar thickness.
orientationMeterGroupOrientation'horizontal' | 'vertical''horizontal'
Horizontal or vertical bar. Vertical fills from bottom to top, the legend beside it.

Slots

SlotType
valueMeterGroupValueSlotProps
Content replacing the sum. Receives value, max and percent.
item-leadingMeterGroupItemSlotProps
Decorative content replacing a row’s swatch or icon. Receives item, index and percent.
item-labelMeterGroupItemSlotProps
Content replacing a row’s label. Receives item, index and percent.
item-valueMeterGroupItemSlotProps
Content replacing a row’s amount. Receives item, index and percent.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender
export interface MeterGroupItem {
  label: string
  value: number
  tone?: MeterGroupTone
  color?: string
  icon?: IconSource
}
export interface MeterGroupItemSlotProps {
  item: MeterGroupItem
  index: number
  percent: number
}
export type MeterGroupTone = 'accent' | 'neutral' | 'success' | 'warning' | 'danger'
export interface MeterGroupValueSlotProps {
  value: number
  max: number
  percent: number
}

CSS variables

TokenValue
--vectis-control-size-bar-thickness-xs0.125rem
--vectis-control-size-bar-thickness-sm0.25rem
--vectis-control-size-bar-thickness-md0.5rem
--vectis-control-size-bar-thickness-lg0.75rem
--vectis-control-size-bar-thickness-xl1.25rem
--vectis-control-size-bar-length10rem
--vectis-control-size-meter-group-swatch0.5rem
--vectis-control-size-meter-segment-gap0.125rem