Skip to content
opsinjs
Edit this page

Components

SourceCitation

Where a piece of health information came from, in plain words, with an optional link to the fuller citation and an optional date it was last checked.

Usage

pnpm dlx shadcn@latest add @opsinjs/source-citation

The @opsinjs namespace is declared in your components.json. Everything it installs is code you then own. There is no runtime package to keep in step.

import { SourceCitation } from "@/components/ui/source-citation"
<SourceCitation
  source="Estimated by your watch from movement and heart rate."
  more={{ label: "Read how this is worked out", href: "/how-it-works" }}
  checkedOn="2026-03-14"
  locale="en-GB"
/>

Examples

Theme
Density
Text
Status
Accent theme
Accent
source-citation · base base · style base-lyraOpen under the product theme

A device estimate naming its own method

The provenance names the device and the class of the figure, so it reads as an estimate. more points at the fuller accuracy document.

Theme
Density
Text
Status
Accent theme
Accent
source-citation-a-device-estimate · base base · style base-lyraOpen under the product theme
source-citation-a-device-estimate.tsx
import { SourceCitation } from "@/components/ui/source-citation"

export default function SourceCitationADeviceEstimate() {
  return (
    <div className="w-full max-w-(--opsin-measure-comfortable,66ch)">
      {/* A stand-in for the value the citation belongs to. It is a phrase and not
          a number on purpose, so this example renders no reading a person could
          read as their own. The citation is what places that value in the
          device-estimated class at the moment it is read. */}
      <p className="m-0 text-opsin-headline [color:var(--foreground)]">
        Your example resting estimate
      </p>
      <div className="mt-opsin-1">
        <SourceCitation
          source="Estimated by your Example Watch from movement and heart rate. It works this out rather than measuring it, so read it as an estimate."
          more={{
            label: "Read how your Example Watch works this out",
            href: "#example",
          }}
          checkedOn="2026-03-14"
          locale="en-GB"
        />
      </div>
    </div>
  )
}

When nobody said where it came from

With no source, the citation prints an admission rather than rendering empty. Markup you wrap a source in is taken at its word.

Theme
Density
Text
Status
Accent theme
Accent
source-citation-no-source-supplied · base base · style base-lyraOpen under the product theme
source-citation-no-source-supplied.tsx
import { SourceCitation } from "@/components/ui/source-citation"

export default function SourceCitationNoSourceSupplied() {
  return (
    <div className="w-full max-w-(--opsin-measure-comfortable,66ch)">
      {/* No `source`, which is what `{reading.source}` looks like on the day the
          data layer has none. The component prints its admission and warns in
          development rather than rendering an empty line. */}
      <SourceCitation />
    </div>
  )
}

When to use it

Use it when

  • Beside a health value whose provenance a reader needs to weigh it: a wearable estimate, a home device reading, a typed figure.
  • To attribute and link a manufacturer's accuracy document or a study you have read, rather than restating its claim as your own.
  • Wherever a number's origin bounds what may be said about it, so origin travels with the number where it is read.

Do not use it when

  • The message is a standing statement about the whole product, rather than the source of one value.Use disclaimer-note instead.
  • You are saying when a reading was taken or synced, rather than where it came from.Use relative-time instead.
  • You are explaining what a term means, rather than where a value came from.Use term instead.
  • The note is information about the content with no source to attribute.Use callout instead.

Clinical meaning

Asserts. Where a health value came from, in the product's own plain words, with an optional checked date and a link to the fuller source.

Never read as. A guarantee that the source is right, current, or checked by anybody. checkedOn is the date the product recorded, and a value old enough to doubt is wrapped in RelativeTime beside it.

Colour axis. Neither: no status prop and no category prop, and a class from either axis raises a development warning. See Two colour axes.

Thresholds. None. No reference range, verdict or clinical number passes through, and the product owns the words. Of the ten provenance rules in Trends and uncertainty, rules 22 to 31, this component carries two, provenance in plain words at the value (rule 23) and a manufacturer's claim attributed rather than restated (rule 27). The other eight stay the caller's, and it renders a wrong string as readily as a right one. opsinjs ships no source, date, DOI or study. See Safety review.

Accessibility

The audit found no axe violation, missed target size, hidden focus or loss at 320px reflow. Both lines are set at text-opsin-footnote, a rem from the generated ramp and never a px size, in --foreground for the source and --muted-foreground for the date, with no raw colour literal or ramp step. more carries the label and the href together, so a link cannot be added without a label, and an external href adds an off-screen "opens in a new tab". The link is not inside a sentence, so it re-adds --opsin-target-minimum on both axes. See Accessibility. It reflows at 200% text with no fixed height, and min-w-0 with wrap-break-word breaks a long device name.

Residual items.

  • The source line, the last-checked time and the fuller-citation link render as loose siblings with no programmatic group binding them. Reading order keeps the association, so this is not an AA failure.
  • The "Last checked on" chrome is always English while the date follows the caller's locale, and when they differ the localised date carries no lang seam yet, per ADR 0005.
KeyActionNotes
TabMoves to the link, when there is oneThe citation is text, not a tab stop. The link is its only focusable element.
Shift+TabMoves back out of the linkReverse order matches visual order. The link is last.
EnterFollows the linkOnly when a link is present. An ordinary anchor, so Enter and not Space.
SpaceScrolls the page, as it does anywhere elseNothing here captures Space or activates on it.
Contrast: 36 measured token pairs, 15 below floor
PairThemeAPCA LcWCAG 2.2Floor
body text on the pagelight101.617.18:1Pass
body text on the pagedark-100.518.00:1Pass
body text on a cardlight104.717.96:1Pass
body text on a carddark-99.616.32:1Pass
body text on the muted groundlight98.116.32:1Pass
body text on the muted grounddark-97.513.77:1Pass
secondary text on the pagelight83.97.42:1Pass
secondary text on the pagedark-80.713.44:1Pass
secondary text on a cardlight87.07.76:1Pass
secondary text on a carddark-79.812.19:1Pass
secondary text on the muted groundlight80.47.05:1Pass
secondary text on the muted grounddark-77.810.28:1Pass
a hairline boundary on the pagelight19.31.41:1Below floor
a hairline boundary on the pagedark-8.21.90:1Below floor
a hairline boundary on a cardlight22.41.47:1Below floor
a hairline boundary on a carddark-7.31.72:1Below floor
a hairline boundary on the muted groundlight15.81.34:1Below floor
a hairline boundary on the muted grounddark0.01.45:1Below floor
a placeholder boundary on the pagelight69.84.52:1Pass
a placeholder boundary on the pagedark-51.07.62:1Pass
a placeholder boundary on a cardlight72.84.72:1Pass
a placeholder boundary on a carddark-50.16.91:1Pass
a placeholder boundary on the muted groundlight66.24.29:1Pass
a placeholder boundary on the muted grounddark-48.15.83:1Pass
a placeholder fill on the pagelight8.31.18:1Below floor
a placeholder fill on the pagedark-8.21.90:1Below floor
a placeholder fill on a cardlight11.41.23:1Below floor
a placeholder fill on a carddark-7.31.72:1Below floor
a placeholder fill on the muted groundlight0.01.12:1Below floor
a placeholder fill on the muted grounddark0.01.45:1Below floor
a placeholder boundary on its own filllight58.93.84:1Pass
a placeholder boundary on its own filldark-41.54.01:1Below floor
the card hairline on the pagelight69.84.52:1Pass
the card hairline on the pagedark-28.74.19:1Below floor
the card hairline on a cardlight72.84.72:1Pass
the card hairline on a carddark-27.93.80:1Below floor

These are the measured token pairs this component draws colour from, not a measurement of the component itself.

Props interface

Prop

Type

Generated from SourceCitationProps in registry/bases/base/source-citation.tsx.

source is typed optional but required by the contract, so the missing state can render. checkedOn is a strict YYYY-MM-DD string or epoch milliseconds, both pinned to UTC. A value that is not a real calendar date is refused, not rendered as a plausible wrong one.