Meter Group
Partition one exact shared capacity into ordered named measurements.
Usage
Grouped capacity
Partition one shared capacity into ordered named measurements and explicit remaining space.
<!-- Meter Group / Grouped Capacity -->
<script setup lang="ts">
import { MeterGroupIndicator, MeterGroupItem, MeterGroupItemIndicator, MeterGroupItemLabel, MeterGroupItemValue, MeterGroupList, MeterGroupRoot, MeterGroupSegment, MeterGroupTrack, MeterGroupValueText } from '@sectile/vue/meter-group-indicator'
const items = [
{ id: 'documents', label: 'Documents', value: '42' },
{ id: 'media', label: 'Media', value: '31' },
{ id: 'archives', label: 'Archives', value: '7' },
] as const
</script>
<template>
<MeterGroupRoot :items="items" max="100" label="Storage capacity">
<MeterGroupValueText />
<MeterGroupTrack>
<MeterGroupSegment v-for="item in items" :key="item.id" :id="item.id">
<MeterGroupIndicator />
</MeterGroupSegment>
</MeterGroupTrack>
<MeterGroupList>
<MeterGroupItem v-for="item in items" :key="item.id" :id="item.id">
<MeterGroupItemIndicator />
<MeterGroupItemLabel />
<MeterGroupItemValue />
</MeterGroupItem>
</MeterGroupList>
</MeterGroupRoot>
</template>Zero values
Keep zero-valued categories in order without assigning them visual capacity.
<!-- Meter Group / Zero Values -->
<script setup lang="ts">
import { MeterGroupIndicator, MeterGroupItem, MeterGroupItemIndicator, MeterGroupItemLabel, MeterGroupItemValue, MeterGroupList, MeterGroupRoot, MeterGroupSegment, MeterGroupTrack, MeterGroupValueText } from '@sectile/vue/meter-group-indicator'
const items = [
{ id: 'documents', label: 'Documents', value: '42' },
{ id: 'archives', label: 'Archives', value: '0' },
] as const
</script>
<template>
<MeterGroupRoot :items="items" max="100" label="Storage capacity">
<MeterGroupValueText />
<MeterGroupTrack>
<MeterGroupSegment v-for="item in items" :key="item.id" :id="item.id">
<MeterGroupIndicator />
</MeterGroupSegment>
</MeterGroupTrack>
<MeterGroupList>
<MeterGroupItem v-for="item in items" :key="item.id" :id="item.id">
<MeterGroupItemIndicator />
<MeterGroupItemLabel />
<MeterGroupItemValue />
</MeterGroupItem>
</MeterGroupList>
</MeterGroupRoot>
</template>Exact decimal
Enter 0.1 as decimal text and preserve it without binary floating-point coercion.
<!-- Meter Group / Exact Decimal -->
<script setup lang="ts">
import { MeterGroupIndicator, MeterGroupItem, MeterGroupItemIndicator, MeterGroupItemLabel, MeterGroupItemValue, MeterGroupList, MeterGroupRoot, MeterGroupSegment, MeterGroupTrack, MeterGroupValueText } from '@sectile/vue/meter-group-indicator'
const items = [
{ id: 'documents', label: 'Documents', value: '0.1' },
{ id: 'media', label: 'Media', value: '0.2' },
] as const
</script>
<template>
<MeterGroupRoot :items="items" max="0.6" label="Storage capacity">
<MeterGroupValueText />
<MeterGroupTrack>
<MeterGroupSegment v-for="item in items" :key="item.id" :id="item.id">
<MeterGroupIndicator />
</MeterGroupSegment>
</MeterGroupTrack>
<MeterGroupList>
<MeterGroupItem v-for="item in items" :key="item.id" :id="item.id">
<MeterGroupItemIndicator />
<MeterGroupItemLabel />
<MeterGroupItemValue />
</MeterGroupItem>
</MeterGroupList>
</MeterGroupRoot>
</template>Invalid input
Reject a partition whose exact total exceeds the shared capacity.
Rejected input: meter-group-total-exceeds-maximum
<!-- Meter Group / Invalid Input -->
<script setup lang="ts">
import { tryCreateMeterGroupState } from '@sectile/core/meter-group'
const result = tryCreateMeterGroupState({
max: '100',
items: [
{ id: 'documents', value: '70' },
{ id: 'media', value: '40' },
],
})
</script>
<template>
<p v-if="!result.ok">Rejected input: {{ result.error.code }}</p>
</template>API
Vue package: @sectile/vue/meter-group
MeterGroupRootMeterGroupTrackMeterGroupSegmentMeterGroupIndicatorMeterGroupValueTextMeterGroupListMeterGroupItemMeterGroupItemIndicatorMeterGroupItemLabelMeterGroupItemValue
Props
MeterGroupRootProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
formatTotalFormats the aggregate value and maximum for visible text.
formatValueFormats a value for visible text.
highLower boundary of the high-value region.
itemsOrdered item values managed by the component.
labelAccessible name announced for the control.
lowUpper boundary of the low-value region.
maxLargest value accepted by the component.
optimumValue that determines which threshold region is optimal.
MeterGroupSegmentProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
idStable ID used to connect related parts.
MeterGroupItemProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
idStable ID used to connect related parts.
MeterGroupPartProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
Slots
MeterGroupSegmentSlotProps
endSegment end value within the shared range.
endPercentageSegment end expressed as a percentage of the shared range.
idStable ID for this field or item.
labelAccessible name announced for the control.
percentageCurrent value expressed as a percentage of its range.
startSegment start value within the shared range.
startPercentageSegment start expressed as a percentage of the shared range.
valueCurrent value exposed by this contract.
valueTextFormatted text for the current range value when available.
MeterGroupRootSlotProps
maxMaximum of the numeric range.
percentageCurrent value expressed as a percentage of its range.
remainingUnallocated value remaining before the shared maximum.
segmentsOrdered segments projected from the shared range.
totalSum of all segment values.
valueTextFormatted text for the current range value when available.
zoneQuality region derived from the thresholds and optimum value.
MeterGroupItemSlotProps
endSegment end value within the shared range.
endPercentageSegment end expressed as a percentage of the shared range.
idStable ID for this field or item.
labelAccessible name announced for the control.
percentageCurrent value expressed as a percentage of its range.
startSegment start value within the shared range.
startPercentageSegment start expressed as a percentage of the shared range.
valueCurrent value exposed by this contract.
valueTextFormatted text for the current range value when available.
Other types
MeterGroupEntry
| Name | Type | Required |
|---|---|---|
id | string | Yes |
value | number | string | Yes |
label | string | Yes |
MeterGroupValueFormatter
type MeterGroupValueFormatter = (value: string, entry: MeterGroupEntry) => stringMeterGroupTotalFormatter
type MeterGroupTotalFormatter = (total: string, max: string) => stringParts
Shared scope: [data-scope="meter-group"]. Combine it with a part selector to keep styles local to this component.
| Part | Selector | Role | Extra attributes |
|---|---|---|---|
root | [data-part="root"] | Names the related set without adding a duplicate aggregate meter. | role="group"data-zone="<zone>"data-percentage="<percentage>" |
track | [data-part="track"] | Preserves the ordered visual track while its meter children retain semantics. | role="presentation" |
segment | [data-part="segment"] | Exposes one named measurement and its exact cumulative offsets. | role="meter"data-id="<id>"data-start-percentage="<percentage>"data-end-percentage="<percentage>" |
indicator | [data-part="indicator"] | Draws the current segment without adding another accessible value. | aria-hidden="true"data-percentage="<percentage>" |
value-text | [data-part="value-text"] | Displays the formatted value as text. | — |
list | [data-part="list"] | Groups the visual legend without repeating the named meter announcements. | aria-hidden="true" |
item | [data-part="item"] | Keeps one legend row keyed to the same Core segment. | data-id="<id>"aria-hidden="true" |
item-indicator | [data-part="item-indicator"] | Shows the item selection state. | — |
item-label | [data-part="item-label"] | Exposes the item label styling region. | — |
item-value | [data-part="item-value"] | Exposes the item value styling region. | — |
Keyboard interaction
| Key | Behavior |
|---|---|
| None | The range display is read-only and defines no keyboard interaction. |
Accessibility
One named group contains ordered, individually named read-only meters; visual track and legend parts add no duplicate aggregate announcement.
