SignalMeter
A segmented bar that shows confidence, relevance or signal as lit segments.
Usage
Four Levels
value decides how many segments light up; unlit segments keep the hairline tone and ignore tone entirely.
Loading demo...
Best Practices
- Colour is never the only carrier of state: put a text label beside the meter (
High confidence/Needs review) and pass that same text aslabel. - Keep
maxconsistent within a screen, or "two of three" and "two of five" read as the same strength. - When the parent already shows a visible label, leave
labeloff so a screen reader announces it once. - Map a semantic value such as
confidencetovalue+tonein the host rather than scattering magic numbers through templates.
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | — | Lit segment count. Required; clamped into [0, max] and truncated toward zero. |
max | number | 3 | Total segment count. |
tone | string | 'currentColor' | Colour of the lit segments, any CSS colour. Inherits the parent's text colour by default. |
label | string | — | Accessible name. Without it the whole meter is marked aria-hidden. |
barHeight | number | 10 | Segment height in px. |
barWidth | number | 4 | Segment width in px. |
Events
The component has no interaction and emits nothing.
Slots
The component has no slots.
Where It Fits
- The confidence footer and alternatives list of a suggestion card —
TxRecommendationCarduses it internally. - Relevance on retrieval results: three segments scan across a column faster than a percentage.
- Any discrete strong / medium / weak / none quantity. Use
TxProgressBarfor continuous ones. - Versus
TxStatusBadge: that is a bordered badge over five semantic tones; this is a bare row of segments that takes any colour, so the two are not interchangeable.
Overview
- A presentation-only primitive: no events, no internal state, repaints when
valuechanges. labeldecides the accessibility semantics. Supply it and the meter rendersrole="img"witharia-label; omit it and the whole meter isaria-hidden="true". The latter is deliberate — three emptyspans announced one at a time are noise, and in real layouts the meter always sits beside its own visible text.- An out-of-range
valueneither throws nor overflows; it is clamped into[0, max]. tonetakes a raw CSS colour string and does not follow the theme. Pass a variable such asvar(--tx-color-success)rather than a hex literal if you want it to.- The fill transition runs 300ms;
prefers-reduced-motion: reducedrops the transition and keeps the final colour.
Technologies
- Component source and types:
packages/tuffex/packages/components/src/signal-meter/src/TxSignalMeter.vueandtypes.ts. - Adapted from Beautiful UI (https://www.beautifului.dev), © 2026 Shane Levine, MIT.
查看源码
packages/tuffex/packages/components/src/signal-meter/index.ts