Level Meter
Segmented audio level meter with peak hold. Zone-tinted segments light in proportion to a live value, under a decaying peak line. The live, vertical counterpart to Meter.
<arc-level-meter>Overview
LevelMeter shows a value that changes many times a second: audio levels, buffer fill, network throughput. It renders a track of segments (twenty by default) that light up in proportion to value. Each segment takes the color of its zone: success below warn, warning between warn and clip, error above clip. Lit segments glow, and unlit ones keep a faint tint of their zone so the scale shows even at silence. Set segments="0" for a continuous bar.
The value maps linearly between min and max, which default to 0 and 1. For dB metering, set the range (min="-60" max="0") and pass dB readings as value. The warn and clip thresholds are always fractions of the range (0.75 and 0.9 by default), so the zones fall in the same place on linear and dB scales.
A thin peak line marks the highest recent level. Left alone, the meter tracks its own peak, holds it briefly, then lets it fall toward the current level on an animation frame loop. With prefers-reduced-motion, the line jumps down instead of sliding. If your audio engine already computes peaks, set the peak property and the line renders exactly there, with no tracking of its own.
One element is one channel. There's no stereo mode, so put two meters side by side for a stereo pair, or a row of them for a mixer. The meter renders no visible text, so label is its only accessible name. role="meter" with aria-valuemin, aria-valuemax and aria-valuenow carries the reading.
Guidelines
Do
- Use it for live readings like audio channels, input gain or buffer health, where Meter would flicker
- Name the channel in `label` ("Master left", not "Level")
- Set `warn` and `clip` to your headroom. The defaults (0.75 and 0.9) suit a linear 0 to 1 signal
Don't
- Don't use it for a static value like disk usage or a score. Use Meter, which has low, high and optimum
- Don't use it for task completion. Use Progress
- Don't feed `value` from slow polling and expect a useful peak line. The tracker only sees the values you give it
- Don't rely on segment color alone to show clipping. Add a clip indicator or text where it matters
Features
- Vertical (the default, filling bottom-up) or horizontal. Horizontal fills from the inline start, so it follows text direction
- The peak loop runs on `requestAnimationFrame`, starts on connect and stops on disconnect, so an unmounted meter does no work
Preview
Usage
Level Meter is in the media group, so the default @arclux/arc-ui entry point doesn't include it. Import it from@arclux/arc-ui/media or from its own subpath,@arclux/arc-ui/level-meter.
<!-- Stereo pair: one meter per channel -->
<div style="display: flex; gap: 4px;">
<arc-level-meter id="ch-l" label="Master left" min="-60" max="0" value="-60"></arc-level-meter>
<arc-level-meter id="ch-r" label="Master right" min="-60" max="0" value="-60"></arc-level-meter>
</div>
<script>
// Drive it at signal rate; the meter tracks its own decaying peak.
analyzer.onLevels = ({ left, right }) => {
document.getElementById('ch-l').value = left; // dB
document.getElementById('ch-r').value = right;
};
</script>import { LevelMeter } from '@arclux/arc-ui-react';
export default function MasterMeters({ left, right }: { left: number; right: number }) {
return (
<div style={{ display: 'flex', gap: 4 }}>
<LevelMeter label="Master left" min={-60} max={0} value={left} />
<LevelMeter label="Master right" min={-60} max={0} value={right} />
</div>
);
}<script setup>
import { LevelMeter } from '@arclux/arc-ui-vue';
defineProps({ left: Number, right: Number });
</script>
<template>
<div style="display: flex; gap: 4px;">
<LevelMeter label="Master left" :min="-60" :max="0" :value="left" />
<LevelMeter label="Master right" :min="-60" :max="0" :value="right" />
</div>
</template><script>
import { LevelMeter } from '@arclux/arc-ui-svelte';
let { left, right } = $props();
</script>
<div style="display: flex; gap: 4px;">
<LevelMeter label="Master left" min={-60} max={0} value={left} />
<LevelMeter label="Master right" min={-60} max={0} value={right} />
</div>import { Component, Input } from '@angular/core';
import { LevelMeter } from '@arclux/arc-ui-angular';
@Component({
imports: [LevelMeter],
template: `
<div style="display: flex; gap: 4px;">
<arc-level-meter label="Master left" [min]="-60" [max]="0" [value]="left"></arc-level-meter>
<arc-level-meter label="Master right" [min]="-60" [max]="0" [value]="right"></arc-level-meter>
</div>
`,
})
export class MasterMeters {
@Input() left = -60;
@Input() right = -60;
}import { LevelMeter } from '@arclux/arc-ui-solid';
export default function MasterMeters(props: { left: number; right: number }) {
return (
<div style={{ display: 'flex', gap: '4px' }}>
<LevelMeter label="Master left" min={-60} max={0} value={props.left} />
<LevelMeter label="Master right" min={-60} max={0} value={props.right} />
</div>
);
}import { LevelMeter } from '@arclux/arc-ui-preact';
export default function MasterMeters({ left, right }: { left: number; right: number }) {
return (
<div style={{ display: 'flex', gap: 4 }}>
<LevelMeter label="Master left" min={-60} max={0} value={left} />
<LevelMeter label="Master right" min={-60} max={0} value={right} />
</div>
);
}API
labelstring''- Accessible name applied as aria-label on the meter. The component renders no visible text, so this is the only name screen readers get; use something like "Master left" rather than "Level".
valuenumber0- Current level. Interpreted against
minandmax, so with the defaults (0 and 1) it is a linear fraction, and withmin="-60" max="0"it is a dB reading. Values outside the range are clamped. minnumber0- Value at the empty end of the meter. Defaults to 0.
maxnumber1- Value at the full end of the meter. Defaults to 1. Use -60..0 (or your headroom of choice) for dB scales.
peaknumber0- Externally supplied peak-hold level, in the same units as
value. When set, the component renders the hold line exactly there and does no tracking of its own. When absent, the meter tracks its own peak from incoming values, holds it briefly, then decays it toward the current level. orientation'vertical' | 'horizontal''vertical'- Meter direction. Vertical (the default) fills bottom-up like a channel strip; horizontal fills from the inline start. Unknown values fall back to vertical.
segmentsnumber20- Number of discrete segments. Defaults to 20. Set 0 for a continuous, unsegmented bar.
warnnumber0.75- Fraction of the range (0..1) where the warning zone begins, regardless of units. Defaults to 0.75.
clipnumber0.9- Fraction of the range (0..1) where the clip (error) zone begins. Defaults to 0.9.
See also
- MeterGauge with color-coded fill zones (success, warning, error) set by `low`, `high` and `optimum` thresholds.
- ProgressA progress bar or spinner for long-running work, with or without a known percentage.
- SparklineA small inline line or bar chart, drawn as SVG from a comma-separated string of numbers.