Skip to content

Meter Examples

The examples below assume that you have imported the component and set up the theme.

Basic

Show a value within a known range, like used storage, and color it by how good it is. value and max set the fill, low, high, and optimum pick the zone color, data-sv-meter-value prints the value, and data-sv-meter-value-text gives screen readers that text.

Storage of 256 GB used
--good--fair--poor
Layout
Sets flex-direction: column-reverse on the meter.
Value
164
Zones
128
200
0
<div class="meter-basic">
<sv-meter aria-label="Storage" high="200" low="128" max="256" optimum="0" value="164">
<span>Storage</span>
<span data-sv-meter-value-text>
<span data-sv-meter-value="0"></span>
of 256 GB used
</span>
</sv-meter>
</div>
<style>
.meter-basic {
display: grid;
justify-items: center;
sv-meter {
inline-size: min(100%, 20rem);
font-size: 0.875rem;
}
.labels-below {
flex-direction: column-reverse;
}
sv-meter[vertical] {
inline-size: auto;
block-size: 10rem;
}
}
</style>