Dev Helpers

React / Statistical displays

Range span readout

Dev Helpers · June 25, 2026

The span of a range differs from the count of discrete values inside it. Define whether endpoints are inclusive before choosing the label.

Worked example

// components/RangeSpanReadout.tsx

export default function RangeSpanReadout({
  values = [2, 3, 3, 6, 11],
}: { values?: number[] } = {}) {
  return (
    <output>
      {values.length
        ? "Span: " + (Math.max(...values) - Math.min(...values))
        : "No observations"}
    </output>
  );
}

Implementation notes

A reversed range can mean invalid input or a deliberate descending sequence. Do not silently take an absolute difference unless that is the intended contract.

Try it yourself

Try equal endpoints and a range whose upper limit is lower than its start.

Open the React example →

Editorial date June 25, 2026 · Published December 6, 2026

Related articles

Percentage meter

A percentage meter needs both a bounded visual fill and a meaningful textual value. Handle a zero denominator before dividing.

Vertical typesetting sample

Vertical typesetting changes the reading direction and available inline space. Treat the sample text as content so it remains selectable and accessible.

Square cover crop

A square image crop gives a card grid consistent geometry. The crop anchor determines whether the most important part of a photo survives.