---
title: "Components"
description: "Sixty components in twelve categories, each installed as source you own."
url: "https://opsinjs.pensievelabs.org/docs/components"
source: "https://opsinjs.pensievelabs.org/docs/components.md"
section: "Components"
kind: "guide"
---

> Elements written as `<PascalCase … />` below are opsinjs documentation
> components. Their attributes are the content: the values they render are
> generated from `tokens/*.json` and `registry/catalogue.ts` and are
> published separately at https://opsinjs.pensievelabs.org/r/index.json and under the Reference
> section.
> Nothing is missing from this page. The data simply does not live in
> the prose.

Every component is `shipped`, which means its source installs and renders and its API may change in any release. Each was audited against WCAG 2.2 AA by its own authors. None has had an independent accessibility review or a clinical review, so none is ready for a production health surface.

## Install [#install]

```bash
npx shadcn@latest add @opsinjs/<name>
```

The CLI copies the component's source and the opsinjs `lib/` files it reads into your project, and adds its npm dependencies. `<name>` is the id in each link below. Add the `@opsinjs` entry to `components.json` first, as [Getting started](../getting-started.mdx) shows.

## Usage [#usage]

```tsx
import { Button } from "@/components/ui/button"
```

```tsx
<Button variant="primary" onClick={save}>
  Save reading
</Button>
```

The import path follows the `ui` alias in `components.json`.

## Health data display [#health-data-display]

| Component                               | Use it for                              |
| --------------------------------------- | --------------------------------------- |
| [ResultCard](./result-card.mdx)         | One test result in full                 |
| [RangeBar](./range-bar.mdx)             | One reading against its range           |
| [ScoreDial](./score-dial.mdx)           | A composite score and its band          |
| [TrendSparkline](./trend-sparkline.mdx) | One measurement over time               |
| [MetricTile](./metric-tile.mdx)         | One reading at a glance                 |
| [StatusPill](./status-pill.mdx)         | A status your product assigned          |
| [RangeLegend](./range-legend.mdx)       | The key to a RangeBar's tones           |
| [TimelineEntry](./timeline-entry.mdx)   | One dated event in a history            |
| [GoalRing](./goal-ring.mdx)             | Progress towards a goal the product set |

## Health communication [#health-communication]

| Component                               | Use it for                          |
| --------------------------------------- | ----------------------------------- |
| [AlertBanner](./alert-banner.mdx)       | Something the reader must know now  |
| [CareCard](./care-card.mdx)             | One instruction at a stated urgency |
| [Term](./term.mdx)                      | A clinical word, explained          |
| [ConsentSheet](./consent-sheet.mdx)     | Asking permission for one thing     |
| [DisclaimerNote](./disclaimer-note.mdx) | The not-medical-advice note         |
| [SourceCitation](./source-citation.mdx) | Where health information came from  |

## Health input [#health-input]

| Component                             | Use it for                             |
| ------------------------------------- | -------------------------------------- |
| [LogSheet](./log-sheet.mdx)           | Recording one reading, dose or note    |
| [ReadingInput](./reading-input.mdx)   | Typing a measurement with its unit     |
| [BodyMap](./body-map.mdx)             | Pointing at a body region              |
| [ScaleInput](./scale-input.mdx)       | A self-report on the product's scale   |
| [DoseTracker](./dose-tracker.mdx)     | Doses already logged, shown as facts   |
| [Questionnaire](./questionnaire.mdx)  | The product's questions, with progress |
| [SymptomPicker](./symptom-picker.mdx) | Symptoms from the product's list       |

## Health formatting [#health-formatting]

| Component                           | Use it for               |
| ----------------------------------- | ------------------------ |
| [Value](./value.mdx)                | Any number with its unit |
| [RelativeTime](./relative-time.mdx) | When something happened  |

## Actions and forms [#actions-and-forms]

| Component                         | Use it for                          |
| --------------------------------- | ----------------------------------- |
| [Button](./button.mdx)            | An action the reader presses        |
| [Link](./link.mdx)                | Going somewhere else                |
| [Field](./field.mdx)              | Label, hint and error for any input |
| [IconButton](./icon-button.mdx)   | An icon-only action                 |
| [Switch](./switch.mdx)            | A setting that applies at once      |
| [Checkbox](./checkbox.mdx)        | One option ticked on or off         |
| [RadioGroup](./radio-group.mdx)   | One choice from a short list        |
| [Select](./select.mdx)            | One choice from a long list         |
| [NumberField](./number-field.mdx) | A non-clinical count with steppers  |
| [Textarea](./textarea.mdx)        | A free-text note                    |
| [Slider](./slider.mdx)            | A coarse, non-clinical preference   |
| [Combobox](./combobox.mdx)        | Typing to narrow a long list        |

## Navigation [#navigation]

| Component                                   | Use it for                        |
| ------------------------------------------- | --------------------------------- |
| [SegmentedControl](./segmented-control.mdx) | Switching between a few views     |
| [TabBar](./tab-bar.mdx)                     | Top-level destinations on a phone |
| [Stepper](./stepper.mdx)                    | Where the reader is in a sequence |
| [Tabs](./tabs.mdx)                          | Panels that share one region      |
| [Accordion](./accordion.mdx)                | Sections that expand and collapse |

## Surfaces [#surfaces]

| Component                | Use it for                             |
| ------------------------ | -------------------------------------- |
| [Surface](./surface.mdx) | The layer under every panel and card   |
| [Card](./card.mdx)       | A bordered group of related content    |
| [Sheet](./sheet.mdx)     | A panel that slides up                 |
| [Dialog](./dialog.mdx)   | A question that must be answered first |

## Feedback [#feedback]

| Component                       | Use it for                         |
| ------------------------------- | ---------------------------------- |
| [Callout](./callout.mdx)        | A note, tip or caveat              |
| [EmptyState](./empty-state.mdx) | A screen with nothing on it yet    |
| [Skeleton](./skeleton.mdx)      | The shape of content still loading |
| [Toast](./toast.mdx)            | Confirming the reader's own action |
| [Progress](./progress.mdx)      | How far through a task             |
| [Spinner](./spinner.mdx)        | A brief wait of unknown shape      |

## Overlay [#overlay]

| Component                | Use it for                            |
| ------------------------ | ------------------------------------- |
| [Tooltip](./tooltip.mdx) | A label the reader can do without     |
| [Popover](./popover.mdx) | A small panel anchored to its control |
| [Menu](./menu.mdx)       | Actions opened from a button          |

## Data display [#data-display]

| Component            | Use it for                            |
| -------------------- | ------------------------------------- |
| [Table](./table.mdx) | Rows and columns, and a chart's twin  |
| [Badge](./badge.mdx) | A neutral count or word, never status |

## Layout [#layout]

| Component                       | Use it for                       |
| ------------------------------- | -------------------------------- |
| [Divider](./divider.mdx)        | A hairline between two groups    |
| [ScrollArea](./scroll-area.mdx) | Scrolling inside a card or panel |

## Utility [#utility]

| Component                               | Use it for                        |
| --------------------------------------- | --------------------------------- |
| [Avatar](./avatar.mdx)                  | A person's picture or initials    |
| [VisuallyHidden](./visually-hidden.mdx) | Text only screen readers announce |

## Choosing a component [#choosing-a-component]

Start from your data, and from who assigned any status it carries.

* A measurement the reader interprets is a ResultCard, or a RangeBar when its place in the range is the point. A MetricTile that needs interpreting is a ResultCard at the wrong size.
* A ScoreDial implies a composite index, so it never shows a single measurement.
* Status appears only where a rule your product owns assigned it, and no component computes one. A category, a trend or a position against a range is not a status. See [Two colour axes](../health/two-colour-axes.mdx).
* Allow at most one urgent surface per screen. See [Alerts](../health/alerts.mdx).
* Decide what each component renders in all five data states: empty, loading, error, stale and partial. See [States](../foundations/states.mdx).

<Todo>
  A rule for choosing between input components. Until then, read each component's page.
</Todo>

## Bundle size [#bundle-size]

You copy source, so you ship only what you import. Per-component sizes are not measured yet. The limit more likely to bite is the budget of three overlapping composited surfaces in [Materials](../foundations/materials.mdx).

<NoDataYet script="scripts/build-registry.mts" />
