Confidence Meter
`<pura-confidence-meter>` is a `role="meter"` whose *motion* carries an agent's confidence, not just its width. The fill shows the value; a specular shimmer sweeps slowly when confidence is high and flickers fast (with a faint jitter) when it is low, so a glance reads certainty before any number does. Drive it from `0..1` (a bare `75` is read as `0.75`), add an optional `state` phase label, and listen for `confidencechange` `{ value, level, state }`. Each instance registers in `window.__puraConfidenceMeters` by `data-pura-id`, and mirrors `data-pura-confidence-{value,level,state}` for agent inspection. Under reduced motion the bar rests while value, color, and ARIA still convey confidence.
Preview
<pura-confidence-meter value="0.92" label="Answer confidence"></pura-confidence-meter>
<script type="module">
const m = document.querySelector('pura-confidence-meter');
m.addEventListener('confidencechange', (e) => console.log(e.detail)); // { value, level, state }
m.setValue(0.4); // or: m.setAttribute('value', '40')
window.__puraConfidenceMeters; // Map<data-pura-id, element>
</script> Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
value | number | 0 | Confidence in 0..1. A bare percentage like "75" is read as 0.75. Clamped. |
state | string | "" | Optional free-form phase label (e.g. "thinking", "verifying", "done"); echoed in the event and aria-label. |
label | string | "" | Optional caption shown above the bar. |
hide-value | boolean | false | Hide the numeric percent readout, leaving the bar and label. |
Installation
pura is copy-paste and dependency-free. Load the whole library, or just this component.
<link rel="stylesheet" href="/pura/tokens.css">
<script type="module" src="/pura/lib/confidence-meter.js"></script> import "./pura/lib/confidence-meter.js";