Skip to content
opsinjs
Edit this page

Components

CareCard

A card that tells you what to do and when. It carries one instruction at one of three urgency levels, with the urgency stated in the heading, not implied.

Usage

pnpm dlx shadcn@latest add @opsinjs/care-card

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 { CareCard } from "@/components/ui/care-card"
<CareCard
  heading="Book a repeat blood test"
  urgency="this-week"
  attribution="Your clinic asks"
/>

Examples

Theme
Density
Text
Status
Accent theme
Accent
care-card · base base · style base-lyraOpen under the product theme

A steady card that still asks for something

status="steady" with urgency="when-convenient" is the routine follow-up.

Theme
Density
Text
Status
Accent theme
Accent
care-card-steady-and-still-asking · base base · style base-lyraOpen under the product theme
care-card-steady-and-still-asking.tsx
import { CareCard } from "@/components/ui/care-card"

export default function CareCardSteadyAndStillAsking() {
  return (
    <div className="w-full max-w-md">
      <CareCard
        heading="Book your next example check"
        urgency="when-convenient"
        attribution="Your example clinic asks"
        reason="Your example clinic reviews this measurement once a year, and the next check is due."
        status="steady"
        statusOf="your last example reading"
        dueBy="2027-03-01"
        locale="en-GB"
        actions={[{ label: "Book a check", href: "#example-booking" }]}
      />
    </div>
  )
}

A deadline the reader is already behind

dueBy renders as a written date and overdue is a product-supplied boolean. No urgency is set; the date is the timing.

Theme
Density
Text
Status
Accent theme
Accent
care-card-a-deadline-that-has-passed · base base · style base-lyraOpen under the product theme
care-card-a-deadline-that-has-passed.tsx
import { CareCard } from "@/components/ui/care-card"

export default function CareCardADeadlineThatHasPassed() {
  return (
    <div className="w-full max-w-md">
      <CareCard
        heading="Book the repeat example measurement your clinic asked for, now that the date has gone by"
        attribution="Your example clinic asks"
        reason="The clinic asked for a repeat by the date below, and this app has not seen one."
        dueBy="2026-01-05"
        locale="en-GB"
        overdue
        actions={[
          {
            label: "Book a repeat",
            href: "#example-booking",
            recommended: true,
          },
          { label: "Ask the clinic why", href: "#example-message" },
        ]}
      />
    </div>
  )
}

The author is missing

The same instruction with and without attribution. Without one, the card says so.

Theme
Density
Text
Status
Accent theme
Accent
care-card-no-author-supplied · base base · style base-lyraOpen under the product theme
care-card-no-author-supplied.tsx
import { CareCard } from "@/components/ui/care-card"

export default function CareCardNoAuthorSupplied() {
  return (
    <div className="gap-opsin-6 flex w-full max-w-md flex-col">
      <div className="gap-opsin-2 flex flex-col">
        <p className="text-opsin-footnote m-0 text-muted-foreground">
          With nobody named as asking
        </p>
        <CareCard
          heading="Repeat the example measurement in 3 months"
          urgency="when-convenient"
          /* Empty, deliberately. This is the state the component is refusing to
             make invisible, and it is one console warning as well as one line on
             the card. */
          attribution=""
          reason="A repeat of this example measurement is due."
        />
      </div>
      <div className="gap-opsin-2 flex flex-col">
        <p className="text-opsin-footnote m-0 text-muted-foreground">
          With the author named
        </p>
        <CareCard
          heading="Repeat the example measurement in 3 months"
          urgency="when-convenient"
          attribution="An automatic reminder from this example app, not a message from your clinic"
          reason="A repeat of this example measurement is due."
        />
      </div>
    </div>
  )
}

When to use it

Use it when

  • The reader must do something, and the product can say what, by when and who asks.
  • A result or a change produced a next step that would otherwise be buried in a paragraph.
  • Aftercare, preparation and follow-up instructions for one person at one moment.

Do not use it when

  • Nothing needs doing, or the content is general information not addressed to this reader.Use callout instead.
  • The message must interrupt because it has only just become true.Use alert-banner instead.
  • You only need to label how much attention a result needs.Use status-pill instead.
  • The instruction is the standing not-medical-advice note that appears on every result.Use disclaimer-note instead.
  • The reader must respond before they can do anything else.Use dialog instead.

Clinical meaning

Asserts. That the named author asks this reader to do this, optionally by a stated date, for a stated reason.

Never read as. Advice from a clinician who has assessed this reader, unless the card says so. attribution is required.

Colour axis. Status only, on the embedded StatusPill. Surface, boundary and heading take no category colour. See Two colour axes.

Thresholds. None. urgency says when to act, status says how much attention the reading needs, neither is derived from the other, and all fifteen pairs render. See Two colour axes, Alerts and High-stakes moments.

No clock. Do this today still says so after midnight. overdue is a product-supplied boolean. See Health.

Accessibility

The card is a section named by aria-label from its heading, so entering it speaks the instruction, and it takes no tab stop. Urgency is text with no glyph or colour, and status is carried by StatusPill as word, glyph and tint, never colour alone. Of two actions, the recommended one is set apart by a bordered shape and a hidden qualifier, not by colour.

Residual items.

  • The sm quiet button and secondary quiet link variants inherit the 44px target floor but were not exercised in a browser.
  • Contrast for the action tones and the timing phrase stays unmeasured, as the report below records.
KeyActionNotes
TabMoves to the first action, then to the secondThe card is not focusable.
Shift+TabMoves back through the actions, then out of the cardActions keep DOM order.
EnterActivates the focused actionNo action is destructive: no dismiss, snooze or delete.
SpaceActivates a focused action that is a buttonAn href action is a link, so Space scrolls.
Arrow keysNothingNot a composite widget.
EscapeNothingNot an overlay.
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 CareCardProps in registry/bases/base/care-card.tsx.

CareUrgency and CareAction are exported from the same file, absent from the table.

export type CareUrgency = "when-convenient" | "this-week" | "today"

export interface CareAction {
  label: string
  href?: string
  onSelect?: () => void
  recommended?: boolean
}

An href action renders a link and an onSelect action a button. Given both, the link wins. headingLevel defaults to 3. A dueBy without locale warns in development.