Result Value
StableA single observation rendered so that the four ways a number can lie to you are all impossible.
Why it exists
The most dangerous component in healthcare software is the one that renders a number, because every one of its failures looks perfect on screen.
A preliminary result rendered identically to a final one: the clinician acts, and the value changes at 04:00. A result with no reference range rendered as though it were normal, because nothing was highlighted. A corrected result that silently replaced the value somebody read an hour ago and wrote into a note. An absent value rendered as an em dash, indistinguishable from a rendering bug, a cancelled test, a haemolysed specimen and a patient who declined the draw. None of the four is a styling problem and none is fixed by a nicer table. Each needs a shape: status is never implicit, an absent range is stated rather than left blank, a correction carries the old number with a line through it because the hazard is the reader's memory of it, and absence is seven sentences.
- Observation
- value[x], dataAbsentReason, status, interpretation, referenceRange including appliesTo, and note. DataAbsentReason renders as seven distinct states rather than one blank.
Playground
Change a prop and watch the component and its code change with it.
- onOpenReport — nothing yet
import { ResultValue } from "@/components/zoblocks/result-value";export default function Example() { return ( <ResultValue density="default" hideAnalyte={false} /> );}Examples
The cases worth copying. Open one in StackBlitz to run it with its dependencies installed.
DataobservationPotassiumCriticalobservationPreliminaryobservationCorrectedobservationMaskedobservationDeclinedobservationUninterpretedobservationNotAsked
A FHIR Observation, unedited
observationPotassiumCriticalThe adapter leaves undefined everything it cannot determine. A missing referenceRange becomes no range — not an empty one, and not a silent assumption of normality.
import { ResultValue, fromObservation } from "@/components/zoblocks/result-value";import { observationPotassiumCritical } from "./_shared/observations";// `now` is the host's, never a clock this component reads: a relative time// computed at render silently ages on a ward workstation left open all shift.const serverTime = "2026-08-03T08:21:00Z";export default function FromFhirExample() { return <ResultValue value={fromObservation(observationPotassiumCritical)} now={serverTime} />;}Seven absences, seven sentences
observationMaskedAn em dash is indistinguishable from a rendering bug, and it asks the reader to guess between three answers with three different next actions. Restricted is the one that is not a gap: a value exists and the reader may not see it.
import { ResultValue, type ResultValueData } from "@/components/zoblocks/result-value";const values: ResultValueData[] = [ { id: "hba1c", analyte: "HbA1c", absent: "not-ordered" }, { id: "trop", analyte: "Troponin I", absent: "awaiting" }, { id: "bc", analyte: "Blood culture", absent: "cancelled" }, { id: "wbc", analyte: "White blood cell count", absent: "specimen-problem", absentDetail: "Haemolysed. Recollection requested.", }, { id: "smoking", analyte: "Smoking status", absent: "declined" }, { id: "tox", analyte: "Toxicology screen", absent: "masked" }, { id: "mg", analyte: "Magnesium", absent: "unknown" },];export default function AbsenceExample() { return ( <div className="grid gap-1.5"> {values.map((value) => ( <ResultValue key={value.id} value={value} /> ))} </div> );}A correction shows the number it replaced
observationCorrectedA badge saying "corrected" does not address the hazard, which is that somebody read the old value an hour ago and wrote it into a note. The old number, struck through, with the time it changed, does.
import { ResultValue } from "@/components/zoblocks/result-value";const now = "2026-08-03T08:21:00Z";export default function CorrectionExample() { return ( <ResultValue now={now} value={{ id: "trop", versionId: "2", analyte: "Troponin I", value: 0.09, unit: "ng/mL", range: { high: 0.04 }, status: "corrected", superseded: { value: "<0.04", at: "14:22 today" }, }} /> );}A delta the component refuses to draw
observationPreliminaryTwo numbers from two assays subtracted from each other is not a delta. Flagging the method change and annotating the number anyway would not help — an annotated wrong number still gets read as a number — so the delta disappears entirely.
import { ResultValue } from "@/components/zoblocks/result-value";export default function DeltaSuppressedExample() { return ( <div className="grid gap-2.5"> <div className="grid gap-1"> <span className="text-xs opacity-60">Same assay — the delta prints.</span> <ResultValue value={{ id: "tsh-same-assay", analyte: "TSH", value: 6.4, unit: "mIU/L", range: { low: 0.4, high: 4.0 }, resultedAt: "2026-02-15T09:00:00Z", prior: { value: 3.1, at: "2026-02-01T09:00:00Z" }, }} /> </div> <div className="grid gap-1"> <span className="text-xs opacity-60"> Different assay — flagged, and the delta disappears entirely. </span> <ResultValue value={{ id: "tsh", analyte: "TSH", value: 6.4, unit: "mIU/L", range: { low: 0.4, high: 4.0 }, resultedAt: "2026-02-15T09:00:00Z", // Same analyte, different assay. No delta is drawn. prior: { value: 3.1, at: "2026-02-01T09:00:00Z", differentMethod: true }, }} /> </div> </div> );}Variants
Every variant is the same accessibility contract and the same keyboard model. Pick by what the surface needs.
Default
Value, unit, interpretation and the qualifier line. For a chart or a detail panel.
density="default"
Compact
Tighter type and spacing, for a grid at forty rows and up.
density="compact"
In a grid
The analyte hidden, because the column header already carries it.
density="compact" hideAnalyte=true
Installation
npx @zoblocks/cli add result-valueFirst install? Run zoblocks init once to say where your @/ alias points. The source is copied into your repository, along with anything it depends on.
clsxtailwind-mergeUsage
Props are the FHIR resource.
import { ResultValue, fromObservation } from "@/components/zoblocks/result-value";import "@/styles/zoblocks-result-value.css";<ResultValue value={fromObservation(observation)} now={serverTime} />Use it when
- Anywhere a single observation is rendered — lab results, vitals, screening scores, device readings, point-of-care tests, patient-reported measures.
- In a results grid with density="compact" and hideAnalyte, so the column header carries the name and the rows carry tabular figures that line up.
- With the prior value supplied, so a delta appears where it is meaningful and is suppressed where it is not.
- In a patient portal, where the absence reasons matter most: a portal that renders an em dash has told the patient nothing and worried them anyway.
Avoid it when
- For a panel of several observations. Compose one per row rather than passing a component array — the reference range and the interpretation belong to a single analyte.
- Without `now` if a relative age matters. Omitting it renders no age at all, which is correct; passing a client clock is not.
- As a general-purpose statistic display. The four failures it is shaped around are clinical, and the shapes cost layout that a dashboard metric does not need.
API
Every prop is typed. Props not listed are forwarded to the root element.
ResultValue
5 propsvaluerequiredResultValueData- Default
— - The result itself, already adapted from FHIR. Use `fromObservation()` rather than building it by hand — the adapter leaves undefined everything it cannot determine, which is what keeps a missing range from becoming an assumed one.
density'compact' | 'default'- Default
"default" - Row height and type scale. Inherited from the nearest density provider when omitted.
hideAnalyteboolean- Default
false - Hides the analyte name, for a grid whose column header already carries it.
nowstring- Default
— - ISO 8601, supplied by the host. Without it no relative time is rendered at all — which is correct. A result with no age is less misleading than one whose age is wrong.
onOpenReport((value: ResultValueData) => void)- Default
— - Opens the specimen chain. Makes the value a button; inert without it.
Accessibility
Screen readers and semantics
- The accessible name is the whole clinical sentence. "Potassium 6.8 millimoles per litre, critical, reference 3.5 to 5.1, final, resulted 41 minutes ago." One string, with everything inside hidden from the tree — because the clinical meaning is in the combination, and six separately-labelled nodes are read as six fragments with pauses between them. 6.8 is unremarkable until the unit, the range and the word critical arrive in the same breath.
- Units are spoken, not spelled. mmol/L reaches a screen reader as "millimoles per litre". Left as the symbol it is read character by character or skipped entirely, and a value without its unit is not a result.
- Direction is a glyph before it is a hue. A delta carries an up or down triangle and a signed number, and the direction reaches the accessible name as a word. The colour is reinforcement, which is the only thing colour is allowed to be here.
- Inert unless there is a report to open. role="group" with a label by default and no tab stop. Given onOpenReport it becomes a real button. A focusable element that does nothing is worse in a grid than anywhere else, because there are five hundred of them.
- Absence is never an em dash. Seven reasons, each with a word and a sentence. An em dash is indistinguishable from a rendering bug and asks the reader to guess between "nobody ordered it", "the specimen haemolysed" and "you are not allowed to see it" — three answers with three different next actions.
Conformance · WCAG 2.2 AA · 7 of 8 pass
| Criterion | Status | How | Evidence |
|---|---|---|---|
| 1.3.1Info and relationships | pass | One labelled group carrying the whole clinical sentence, with every inner node aria-hidden. The relationship between value, unit, range and status is in the sentence rather than in visual adjacency. | result-value.test.tsx |
| 1.4.1Use of colour | pass | Interpretation is a ClinicalStatus chip with a shape and a word; delta direction is a glyph and a signed number. No fact is carried by hue alone, and a test asserts the value itself is never coloured by interpretation. | result-value.test.tsx |
| 4.1.2Name, role, value | pass | role="group" with a composed label when static; a real button when onOpenReport is supplied. Never a focusable div. | result-value.test.tsx |
| 2.1.1Keyboard | pass | The report affordance is a native button, reached and activated by keyboard with no handler of the component's own. | result-value.test.tsx |
| 2.5.8Target size | pass | The interactive form holds a 24px minimum at both densities, with negative inline margin so the larger hit area does not shift the column. | result-value.test.tsx |
| 1.4.10Reflow | pass | The qualifier line wraps below the value at narrow widths and the interpretation word never truncates — a truncated "criti…" is worse than no chip. | result-value.test.tsx |
| 1.4.12Text spacing | pass | No fixed heights anywhere; both lines are flex rows that grow with user line-height and letter-spacing rather than clipping. | result-value.test.tsx |
| 2.2.1Timing adjustable | n/a | No timing of any kind. The relative age is computed from a `now` the host supplies, never from a clock the component reads. | — |
Clinical
Every number a clinician reads, and every number a patient reads in a portal. Screening scores are observations too: a PHQ-9 of 14 with status amended because the patient revised item 9 after the session is exactly this component's problem, at a much higher consequence than a sodium.
- Industries
- healthcare, behavioral-health
- Workflows
- assessment, documentation, treatment-planning, medication
- Terminology
- LOINC, SNOMED CT, FHIR
- Permissions
- observation.read
- Audit
- Emits no AuditEvent
Protected health information
Handles PHI
Renders a clinical value and its context. The masked absence exists precisely so a restricted result can be acknowledged on a screen without disclosing it — the reader learns a value exists and that they may not see it, which is a different fact from there being no value.
Source
Exactly what lands in your repository, read from the published registry so it can never drift from what the CLI installs.
Show sourceHide source281 lines
/** * ResultValue — a single observation, rendered so the four ways it can lie are * all impossible. * * <ResultValue value={potassium} now={serverTime} /> * <ResultValue value={fromObservation(observation)} density="compact" /> * * The four failures it exists to prevent, each with the shape that prevents it: * * a preliminary result that looks final → status is always rendered * a rangeless result that looks normal → "not interpreted", never blank * a correction that replaced what you read → the superseded value is shown * an absence rendered as an em dash → seven reasons, seven sentences * * `now` is a prop, not a clock. A relative time computed at render is * untestable, non-deterministic in a screenshot, and on a ward workstation * left open all shift it silently ages. * * Memoised on `(id, versionId)`: a grid of five hundred rows re-renders none of * them when a filter changes, and re-renders exactly the one that was * corrected. * * Styling lives in `styles/zoblocks-result-value.css`, installed alongside. */import * as React from "react";import { cn } from "@/lib/utils";import { ClinicalStatus } from "@/components/zoblocks/clinical-status";import { ABSENCE, PROVENANCE_LABEL, describeElapsed, describeResult, formatRange, resolveDelta, resolveInterpretation, type ResultValueData,} from "@/lib/zoblocks-result-value";export { ABSENCE, ABSENT_REASONS, PROVENANCE_LABEL, describeElapsed, describeRange, describeResult, formatRange, fromDataAbsentReason, fromObservation, resolveDelta, resolveInterpretation, type ResultAbsence, type Interpretation, type PriorValue, type Provenance, type ReferenceRange, type ResultValueData,} from "@/lib/zoblocks-result-value";export interface ResultValueProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> { /** * The result itself, already adapted from FHIR. Use `fromObservation()` rather than building * it by hand — the adapter leaves undefined everything it cannot determine, which is what * keeps a missing range from becoming an assumed one. */ value: ResultValueData; /** * ISO 8601, supplied by the host. * * Without it no relative time is rendered at all — which is correct. A * result with no age is less misleading than one whose age is wrong. */ now?: string; /** Row height and type scale. Inherited from the nearest density provider when omitted. */ density?: "compact" | "default"; /** Hides the analyte name, for a grid whose column header already carries it. */ hideAnalyte?: boolean; /** Opens the specimen chain. Makes the value a button; inert without it. */ onOpenReport?: (value: ResultValueData) => void;}function ResultValueImpl({ value: data, now, density = "default", hideAnalyte = false, onOpenReport, className, ...rest}: ResultValueProps) { const interpretation = resolveInterpretation(data); const delta = resolveDelta(data); const range = formatRange(data.range); const sentence = describeResult(data, now); /* * One accessible name for the whole thing, and everything inside hidden * from the tree. * * The alternative is six labelled nodes, which a screen reader reads as six * fragments with pauses between them — and the clinical meaning of a result * is in the *combination*: 6.8 is unremarkable until you hear the unit, the * range and the word "critical" in the same breath. */ const shell = { className: cn("zb-rv", className), "data-zb-result": "", "data-zb-density": density, "data-zb-absent": data.absent ?? undefined, "data-zb-interpretation": interpretation?.step ?? undefined, "data-zb-status": data.status ?? undefined, "aria-label": sentence, ...rest, }; const body = data.absent ? <Absent data={data} /> : <Present data={data} />; const qualifiers = ( <> {/* The range, or the explicit absence of one. Never nothing: a number with nothing beside it reads as in range, and that is the second of the four failures. */} {range ? ( <span className="zb-rv__range"> {range} {data.range?.appliesTo ? ( <span className="zb-rv__applies"> {data.range.appliesTo}</span> ) : null} </span> ) : data.noRangeReason ? ( <span className="zb-rv__range" data-zb-norange=""> {data.noRangeReason} </span> ) : null} {data.status ? ( <ClinicalStatus scale="result-status" step={data.status} shape="chip" density="compact" aria-hidden="true" /> ) : null} {data.provenance && data.provenance !== "lab" ? ( <span className="zb-rv__provenance" data-zb-provenance={data.provenance}> {PROVENANCE_LABEL[data.provenance]} </span> ) : null} {now && data.resultedAt ? <Age at={data.resultedAt} now={now} /> : null} {(data.notes ?? []).map((note) => ( <span key={note} className="zb-rv__note"> {note} </span> ))} </> ); const content = ( <> <span className="zb-rv__line" aria-hidden="true"> {hideAnalyte ? null : <span className="zb-rv__analyte">{data.analyte}</span>} {body} {interpretation && !data.absent ? ( <ClinicalStatus scale="criticality" step={interpretation.step} shape="chip" density="compact" aria-hidden="true" /> ) : null} {delta && delta.direction !== "flat" ? ( <span className="zb-rv__delta" data-zb-direction={delta.direction}> {delta.direction === "up" ? "▲" : "▼"} {Math.abs(delta.change)} <span className="zb-rv__delta-since"> / {describeElapsed(delta.sinceMs)}</span> </span> ) : null} </span> {/* The superseded value, struck through, with when it changed. Not a badge saying "corrected": the hazard is the clinician's memory of the old number, and a badge does not address it. Showing the old number with a line through it does. */} {data.superseded ? ( <span className="zb-rv__superseded" aria-hidden="true"> <s>{data.superseded.value}</s> superseded {data.superseded.at} </span> ) : null} <span className="zb-rv__qualifiers" aria-hidden="true"> {qualifiers} </span> </> ); if (onOpenReport) { return ( <button {...(shell as React.ButtonHTMLAttributes<HTMLButtonElement>)} type="button" onClick={() => onOpenReport(data)} > {content} </button> ); } // `role="group"` with a label rather than a focusable div: there is nothing // to activate, so there must be no tab stop. return ( <div {...(shell as React.HTMLAttributes<HTMLDivElement>)} role="group"> {content} </div> );}function Present({ data }: { data: ResultValueData }) { return ( <span className="zb-rv__value"> {data.comparator ? <span className="zb-rv__comparator">{data.comparator}</span> : null} <span className="zb-rv__number">{data.value}</span> {data.unit ? <span className="zb-rv__unit">{data.unit}</span> : null} </span> );}/** * Absence, in the slot the number would occupy. * * A word and a sentence, never an em dash — which is indistinguishable from a * rendering bug, and which asks the reader to guess between "nobody ordered * it", "the specimen haemolysed" and "you are not allowed to see it". */function Absent({ data }: { data: ResultValueData }) { // Only ever rendered when `absent` is set; the guard keeps that true at the // type level rather than by assertion. if (!data.absent) return null; const copy = ABSENCE[data.absent]; return ( <span className="zb-rv__value" data-zb-absent-value=""> <span className="zb-rv__absent-word">{copy.short}</span> <span className="zb-rv__absent-detail">{data.absentDetail ?? copy.detail}</span> </span> );}function Age({ at, now }: { at: string; now: string }) { const elapsed = Date.parse(now) - Date.parse(at); if (!Number.isFinite(elapsed) || elapsed < 0) return null; return <span className="zb-rv__age">{describeElapsed(elapsed)} ago</span>;}/** * Memoised on identity and version. * * A results grid re-renders on every filter keystroke, and each row does range * arithmetic, delta arithmetic and sentence composition. Comparing the whole * object would defeat that — hosts rebuild these from a query response, so the * reference changes every time even when nothing did. `versionId` is the * field that actually moves when the record does. */export const ResultValue = React.memo(ResultValueImpl, (a, b) => { return ( a.value.id === b.value.id && a.value.versionId === b.value.versionId && a.now === b.now && a.density === b.density && a.hideAnalyte === b.hideAnalyte && a.onOpenReport === b.onOpenReport && a.className === b.className );});ResultValue.displayName = "ResultValue";