Components
DoseTracker
A record of medicine doses a product has logged, drawing each as a fact with a word and a shape, never computing adherence or judging a missed dose.
Usage
pnpm dlx shadcn@latest add @opsinjs/dose-tracker
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 { DoseTracker } from "@/components/ui/dose-tracker"<DoseTracker
label="Today's doses"
now={new Date().toISOString()}
entries={[
{ name: "Morning tablet", time: "2026-03-14T08:00:00+00:00", state: "taken" },
{ name: "Afternoon tablet", time: "2026-03-14T15:00:00+00:00", state: "missed" },
]}
/>Examples
dose-tracker · base base · style base-lyraOpen under the product themeA day's doses
A day's medicines as the product logged them, some taken, one missed, one skipped, driven by each entry's state. In greyscale the states are still told apart by their words and shapes.
dose-tracker-a-days-doses · base base · style base-lyraOpen under the product themeimport { DoseTracker } from "@/components/ui/dose-tracker"
const NOW = "2026-03-14T20:00:00+00:00"
export default function DoseTrackerADaysDoses() {
return (
<DoseTracker
label="A day's doses"
now={NOW}
entries={[
{ name: "Morning tablet", time: "2026-03-14T08:00:00+00:00", state: "taken" },
{ name: "Midday capsule", time: "2026-03-14T12:30:00+00:00", state: "taken" },
{ name: "Afternoon tablet", time: "2026-03-14T15:00:00+00:00", state: "missed" },
{ name: "Evening drops", time: "2026-03-14T19:00:00+00:00", state: "skipped" },
]}
/>
)
}A missed dose
One state="missed" entry, shown as a fact and left there: a word, a shape, a time, no red, no next step and no adherence figure.
dose-tracker-a-missed-dose · base base · style base-lyraOpen under the product themeimport { DoseTracker } from "@/components/ui/dose-tracker"
const NOW = "2026-03-14T20:00:00+00:00"
export default function DoseTrackerAMissedDose() {
return (
<DoseTracker
label="Recent doses"
now={NOW}
entries={[
{ name: "Morning tablet", time: "2026-03-14T08:00:00+00:00", state: "taken" },
{
name: "Afternoon tablet",
time: "2026-03-14T15:00:00+00:00",
state: "missed",
note: "Marked by you",
},
]}
/>
)
}When to use it
Use it when
- A record of medicine doses the product has already logged, taken and missed together, read as history.
- A day's doses as plain facts, each state a word and a shape beside its time, nothing computed across rows.
- Anywhere the product owns the schedule and the drug data and needs only the log drawn.
Do not use it when
- You are logging a general daily entry, such as a symptom or a note, not a dose with a state.Use
log-sheetinstead. - You need to tell the reader what to do next. That is advice, and this component asserts only facts.Use
care-cardinstead. - You are showing a single reading or figure rather than a list of dose events.Use
metric-tileinstead.
Clinical meaning
Asserts. Exactly the log the product handed it: these medicines, at these times, in these states. A "Missed" marker says the product recorded that dose as missed, and nothing further.
Never read as. Advice, a diagnosis, an adherence score or an instruction. A "Missed" row names a fact, never a fault or a next step, and no percentage is computed, because that would be a clinical figure nobody authored. Health draws the line between recording a fact and prescribing a response.
Colour axis. Neither. A dose state is a fact, not a level of urgency, so no marker carries data-status or data-category. Each marker is neutral chrome with a word and a distinct shape, so the four states survive greyscale. Painting a missed dose the red that means "act now" is the axis mixing Two colour axes forbids.
Thresholds. The consuming product, always. DoseTracker ships no schedule, no drug data, no dose, no threshold and no default text, because each would be a clinical claim Safety review says a presentation layer cannot make.
Time. Each entry's time and now go to RelativeTime unmodified, so it owns what a stale or future instant renders as. Trends and uncertainty is the rule it keeps.
Accessibility
The rendered pass was clean and the source needed no change. Each marker shape is aria-hidden beside a visible word (1.1.1), a real ul/li carries the list semantics (1.3.1), and each state is told by a word and a distinct lucide shape, with no status colour, category colour or colour literal. Icons are em-sized, so at 200% text they grow with the step and the times wrap rather than clip, and no type size is in px.
Residual items.
- The list's accessible name comes only from
label, as anaria-label. Every example supplies one, but a persistent visible label is a recommended enhancement. - No
aria-liveregion is announced: this static read-only log renders once and never updates in place, so 4.1.3 owes no status message. - With no interactive element, target size (2.5.8), focus visibility and keyboard operation do not apply.
- Every contrast pair of hairline and muted ink against the host ground is unmeasured, and so are the markers under
forced-colors: active.
| Key | Action | Notes |
|---|---|---|
| Tab | Skips the whole component | Nothing is focusable. The tracker is a record to read, not a control. |
| Shift+Tab | Skips the whole component | Same in reverse. Never in the focus order. |
| Arrow keys | Nothing | Nothing to select, move or expand. The entries are static content. |
Contrast: 36 measured token pairs, 15 below floor
| Pair | Theme | APCA Lc | WCAG 2.2 | Floor |
|---|---|---|---|---|
| body text on the page | light | 101.6 | 17.18:1 | Pass |
| body text on the page | dark | -100.5 | 18.00:1 | Pass |
| body text on a card | light | 104.7 | 17.96:1 | Pass |
| body text on a card | dark | -99.6 | 16.32:1 | Pass |
| body text on the muted ground | light | 98.1 | 16.32:1 | Pass |
| body text on the muted ground | dark | -97.5 | 13.77:1 | Pass |
| secondary text on the page | light | 83.9 | 7.42:1 | Pass |
| secondary text on the page | dark | -80.7 | 13.44:1 | Pass |
| secondary text on a card | light | 87.0 | 7.76:1 | Pass |
| secondary text on a card | dark | -79.8 | 12.19:1 | Pass |
| secondary text on the muted ground | light | 80.4 | 7.05:1 | Pass |
| secondary text on the muted ground | dark | -77.8 | 10.28:1 | Pass |
| a hairline boundary on the page | light | 19.3 | 1.41:1 | Below floor |
| a hairline boundary on the page | dark | -8.2 | 1.90:1 | Below floor |
| a hairline boundary on a card | light | 22.4 | 1.47:1 | Below floor |
| a hairline boundary on a card | dark | -7.3 | 1.72:1 | Below floor |
| a hairline boundary on the muted ground | light | 15.8 | 1.34:1 | Below floor |
| a hairline boundary on the muted ground | dark | 0.0 | 1.45:1 | Below floor |
| a placeholder boundary on the page | light | 69.8 | 4.52:1 | Pass |
| a placeholder boundary on the page | dark | -51.0 | 7.62:1 | Pass |
| a placeholder boundary on a card | light | 72.8 | 4.72:1 | Pass |
| a placeholder boundary on a card | dark | -50.1 | 6.91:1 | Pass |
| a placeholder boundary on the muted ground | light | 66.2 | 4.29:1 | Pass |
| a placeholder boundary on the muted ground | dark | -48.1 | 5.83:1 | Pass |
| a placeholder fill on the page | light | 8.3 | 1.18:1 | Below floor |
| a placeholder fill on the page | dark | -8.2 | 1.90:1 | Below floor |
| a placeholder fill on a card | light | 11.4 | 1.23:1 | Below floor |
| a placeholder fill on a card | dark | -7.3 | 1.72:1 | Below floor |
| a placeholder fill on the muted ground | light | 0.0 | 1.12:1 | Below floor |
| a placeholder fill on the muted ground | dark | 0.0 | 1.45:1 | Below floor |
| a placeholder boundary on its own fill | light | 58.9 | 3.84:1 | Pass |
| a placeholder boundary on its own fill | dark | -41.5 | 4.01:1 | Below floor |
| the card hairline on the page | light | 69.8 | 4.52:1 | Pass |
| the card hairline on the page | dark | -28.7 | 4.19:1 | Below floor |
| the card hairline on a card | light | 72.8 | 4.72:1 | Pass |
| the card hairline on a card | dark | -27.9 | 3.80:1 | Below 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 DoseTrackerProps in registry/bases/base/dose-tracker.tsx.
An empty entries array renders nothing and warns in development. A state outside the four renders its row with no marker and warns, never approximated into a shape. now is required: read the clock once per screen and pass the same instant to every timestamp. label is the list's aria-label.