Components · Structure

View heading

Names the view, sets the document title, and is where focus lands when the route changes.

Stable · v1.0 shadcn/ui WCAG 2.2 AA

Overview

The view heading looks like a piece of typography and is mostly a piece of behaviour. It names the view, it sets the browser tab so a clinician with four tabs open can tell which patient is in which, and it is what receives focus when the route changes — the commonest defect in a client-rendered application is that nothing does.

How these four sit together — the anatomy of a screen, how deep a hierarchy may go, and what has to happen on a route change — is on Navigation.

Moving between screens

This is where a navigation component stops being a list of links and starts being a piece of software, and it is where most of the real defects are.

Leaving a screen that is doing something

Navigating away is the one moment the interface can lose work or lose sight of a condition. Unsaved entry prompts rather than being discarded, per Textarea. An active alarm does not stop navigation — the clinician may be moving because of it — but the alarm travels, because the alarm layer sits above the view being replaced. And work still running is reported somewhere the reader will see it, rather than completing into a screen nobody is on — see Pending & unreviewed work.

What the component enforces, and what it only asks for

Unusually, the behaviour is held and the content is not — and here the content is the part with a wrong-patient consequence.

RuleHeld by How
Focus moves here on a route changeThe component Keyed on viewKey, to a heading with tabIndex={-1}. Without it a keyboard user is left on a control that no longer exists.
Asserted: ViewHeading: a route change moves focus to the new heading
The arrival is announcedThe component Once, by focus: a screen reader reads the heading it lands on. A polite live region also repeated the same words fifty milliseconds later, so every arrival was spoken twice. Focus does not move on the first render, which on page load skipped the skip link.
Asserted: AX tree: the view heading is a heading that takes focus, and is announced once
The document title is setThe component From documentTitle, on every view change.
Asserted: ViewHeading: the document title follows the view
The title names the subjectYou It is a string. A tab reading “ECG review” for four different patients is how a clinician with several tabs open acts in the wrong one.
viewKey actually changes between viewsYou Pass a stable key and focus never moves, which is the defect this component exists to prevent, wearing the component that prevents it.
Why this is written down

A rule stated on a component page reads as a rule the component keeps. 3 of these 5 are; 2 are obligations this page was quietly handing to the reader. The mechanism is reliable and silent when misused. Both of the rules that are yours fail without any visible symptom.

Do's and don'ts

Do

On arriving at a new view:
focus moves to its heading · title updates · "Troponin trend" announced politely

A keyboard user starts where the content does; a screen-reader user is told they arrived. Neither is true by default in a client-rendered application.

Don't

On arriving at a new view:
the panel highlight moves.

Focus was left on a link that no longer exists, so it reset to the top of the document. Nothing was announced. Invisible in testing with a mouse.

Do

ECG review

tab: ECG review — HARLAND, A.

The document title names the patient. A clinician with four tabs open can tell which is which from the tab strip.

Don't

ECG review

tab: AcuteLine

Four tabs, four patients, one title. The clinician acts in the wrong one, and the tab strip gave them no way to know.

Do

→ route changes → focus lands on Troponin review

announced: “Troponin review”

A keyboard user is told they arrived, and where.

Don't

→ route changes → focus: (top of document)

The route changed and nothing moved. Focus was on a link that no longer exists, so the browser reset it to the top, and a screen-reader user has to hunt for what happened.

Accessibility

Outcomes of use

Clinical safety notes

Risk controls this page specifies

Trace these in your risk file (ISO 14971) and usability engineering file (IEC 62366-1). Which of these the component keeps and which are yours is stated in the guarantees table; a control the component does not keep is one your risk file must show you keep.

Implementation

$ npx shadcn@latest add https://md.notjustany.tech/r/view-heading.json
<ViewHeading
  viewKey={pathname}   // changing it moves focus and re-announces
  documentTitle={`ECG review — ${patient.display}`}
>ECG review</ViewHeading>
NotJustAnyMed.Tech Design System · Navigation · v1.0 · draft for review
Covers Masthead, Side navigation and Breadcrumb. AcuteLine is a fictional reference application; all patient data shown is fabricated.