Dose Input

Flags error-prone dose notation as it is typed and doses ten times outside the usual range, so a slipped decimal isn't read as a ten-fold dose.

StopsTen-fold medication dose error

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/dose-input.json

The files land in your project. They're yours to edit.

Usage

dose-input-usage.tsx
import { DoseInput } from "@/components/ui/dose-input"

<DoseInput label="Warfarin" defaultValue="5.0mg" range={{ min: 1, max: 10, unit: "mg" }} />

What it catches

  • Trailing zeros (1.0 mg) and missing leading zeros (.5 mg)
  • Error-prone abbreviations: U, IU, µg, cc
  • A unit typed flush against the number, and large numbers without separators
  • Doses 10× outside the range you pass (mg typed for mcg, a slipped decimal)
  • The dose spelled back in words

Props

DoseInput props
PropTypeDefault
label

Visible label, usually the drug name.

string"Dose"
value

Controlled text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the text on every change, including one-tap fixes.

(value: string) => void—
range

Typical dose range for this drug. Doses 10× outside it are flagged with likely meant values.

DoseRange—
defaultUnit

Unit assumed and suggested when none is typed. Defaults to the range's unit.

DoseUnit—
messages

Override any string.

Partial<typeof DOSE_MESSAGES>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible <label>; aria-describedby to an aria-live="polite" hint
  • aria-invalid when the dose can't be read
  • Fixes and suggested values are buttons with visible text, returning focus to the input

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Validate doses against the prescribing system's drug database and require clinical review; this field is a typing aid.

  • Not a clinical decision tool: it does not know the patient, the drug or safe dosing
  • Range checks only work with the range you supply
  • Not a medical device; dosing must be checked by a qualified professional

Rules

Rules last verified:

Informational, not medical advice. Checked that the ISMP list covers trailing and missing leading zeros, U, IU and µg. Not every flagged pattern was matched line by line. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

Ten-fold medication dose error

Also known as

dose · dosage · medication · prescription · mg mcg · ehr · pharmacy · healthtech

Field type

Dependencies

Pairs well with