When to use it#
- Use it around text that people read: an article, guidance, a confirmation page or the body of a message.
- Write plain
h1toh6,p,ulandainside it. Prose styles them, so you need no component for each. - Use it for the description of a field or a group of fields: inside a Field or Fieldset it is linked to the control, so a screen reader reads it with the control.
- Not for a region with its own surface: use a Section and put the Prose inside it. Not for a help text that helps while typing: that is a
Field.HelpText.
Example#
import { Prose } from '@kvirn-ui/react'
import { useProseTexts } from './texts.ts'
export function DefaultProse() {
const { texts } = useProseTexts()
return (
<Prose>
<h2>{texts.contact.heading}</h2>
<p>{texts.contact.text}</p>
<p>
{texts.contact.hours} <a href="#example">{texts.contact.link}</a>.
</p>
</Prose>
)
}Use cases#
A page of text
Render the Prose as an article when the text is a piece of content in its own right. The element keeps its own meaning: Prose adds nothing to it.
What you need to apply for a parking permit.
Before you apply
Have these ready:
- Your registration number
- Your personal identity number
- A valid email address
import { Prose } from '@kvirn-ui/react'
import { useProseTexts } from './texts.ts'
export function ArticleProse() {
const { texts } = useProseTexts()
return (
<Prose as="article">
<p className="kv-lead">{texts.article.lead}</p>
<h2>{texts.article.heading}</h2>
<p>{texts.article.intro}</p>
<ul>
{texts.article.items.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
</Prose>
)
}Props in this example:
ason Prose
Larger text for long reading
For guidance that residents read in full, add the kv-prose--large class. The size is set in rem, a unit that follows the browser’s text-size setting, so the text still resizes.
Your application is received
We reply within ten working days. Keep the case number from the confirmation email.
import { Prose } from '@kvirn-ui/react'
import { useProseTexts } from './texts.ts'
export function LargeProse() {
const { texts } = useProseTexts()
return (
<Prose className="kv-prose--large">
<h2>{texts.large.heading}</h2>
<p>{texts.large.text}</p>
</Prose>
)
}Props in this example:
classNameon Prose
A description of a field
Inside a Field, a Prose is the description of the control. A screen reader reads it with the control, before any error message. Write it as Field.Prose, or Fieldset.Prose for a group.
You find it in the registration certificate, in the box marked A.
import { Field, TextInput } from '@kvirn-ui/react'
import { useProseTexts } from './texts.ts'
export function FieldDescription() {
const { texts } = useProseTexts()
return (
<Field.Root>
<Field.Label>{texts.field.label}</Field.Label>
<Field.Prose>
<p>{texts.field.description}</p>
</Field.Prose>
<TextInput name="registration" autoComplete="off" />
</Field.Root>
)
}Warning: Don't forget
A screen reader reads a description as plain text, so a heading, list or link in it loses its structure, and the link can’t be followed. Keep it to a few short paragraphs, so the instructions reach everyone (3.3.2 Labels or Instructions). See What you need to do.
A paragraph that must not be missed
Set a condition, an exception or a tip apart from the text around it with the kv-inset class. It is part of the article, has no role, and nothing is announced. A deadline that loses someone their right, or money, is an Alert (Alert.Warning) instead.
What you need to apply for a parking permit.
Important: Each car needs its own permit. Apply once for every registration number.
import { Prose } from '@kvirn-ui/react'
import { useProseTexts } from './texts.ts'
export function InsetTextProse() {
const { texts } = useProseTexts()
return (
<Prose>
<p>{texts.article.lead}</p>
<div className="kv-inset">
<p>
<strong>{texts.inset.lead}</strong> {texts.inset.text}
</p>
</div>
</Prose>
)
}Warning: Don't forget
Start an inset with a word that says why it is set apart, such as “Important:”. The bar and the fill aren’t read aloud, and colour must never be the only cue (1.4.1 Use of Color).
A process in order
Write the steps as an ordinary numbered list (ol) with the kv-steps class. Every step has a heading and text, or none has a heading. Start each heading with a verb. The list keeps its numbers and its list role. An automated test checks this in Chromium, so check the same in Safari with VoiceOver.
How it works
Apply in the e-service
It takes about ten minutes.
Wait while we check your application
We contact you if something is missing.
Read your decision
It arrives by post within ten working days.
Pay the fee
The invoice comes with the decision.
import { Prose } from '@kvirn-ui/react'
import { useProseTexts } from './texts.ts'
export function StepsProse() {
const { texts } = useProseTexts()
return (
<Prose>
<h2>{texts.steps.heading}</h2>
<ol className="kv-steps">
{texts.steps.items.map((item) => (
<li key={item.title}>
<h3>{item.title}</h3>
<p>{item.text}</p>
</li>
))}
</ol>
</Prose>
)
}Information: Did you know?
Steps or Stepper: steps are guidance to read, in one page. They are not a progress indicator in a form, which is a Stepper.
A picture with a caption
Wrap the picture in a figure with a figcaption. The alt text says what the picture shows, and the caption holds the source or credit, so the two never repeat each other.
Zone B has 40 spaces. The entrance is on the north side, next to the pay station.
import { Prose } from '@kvirn-ui/react'
import { useProseTexts } from './texts.ts'
const zoneMap =
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 160'%3E%3Crect width='320' height='160' fill='%23f2f2f2'/%3E%3Crect x='24' y='40' width='272' height='96' fill='none' stroke='%23333' stroke-width='3'/%3E%3Crect x='136' y='28' width='48' height='24' fill='%23333'/%3E%3C/svg%3E"
export function ImagesAndMediaProse() {
const { texts } = useProseTexts()
return (
<Prose>
<figure>
<img src={zoneMap} width={320} height={160} alt={texts.figure.alt} />
<figcaption>{texts.figure.caption}</figcaption>
</figure>
<p>{texts.figure.description}</p>
</Prose>
)
}Warning: Don't forget
Put every fact a picture carries in the text next to it (1.1.1 Non-text Content). For video, host the file yourself and add captions (1.2.2 Captions (Prerecorded)). Don’t embed a video from another site: it makes your visitors’ browsers contact that site.
Text from a CMS
When a component of your own renders text from a CMS, spread the hook’s props on its root element so the body gets the prose styles.
Processing times
Most applications are decided within ten working days.
A decision can take longer in July. You can see why:
- The case officers are on leave
- Your application is missing a document
import { mergeProps, useProse } from '@kvirn-ui/react'
import type { CmsBlock } from './texts.ts'
import { useProseTexts } from './texts.ts'
function RichText({
blocks,
className,
}: {
blocks: readonly CmsBlock[]
className?: string | undefined
}) {
const prose = useProse()
return (
<div {...mergeProps({ className }, prose.rootProps)}>
{blocks.map((block) => {
switch (block.type) {
case 'heading':
return <h2 key={`heading-${block.text}`}>{block.text}</h2>
case 'paragraph':
return <p key={`paragraph-${block.text}`}>{block.text}</p>
case 'list':
return (
<ul key={`list-${block.items.join()}`}>
{block.items.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
)
}
})}
</div>
)
}
export function CmsText() {
const { texts } = useProseTexts()
return <RichText blocks={texts.cms.blocks} />
}Warning: Don't forget
CMS content still needs real headings in order and real lists (1.3.1 Info and Relationships). Prose styles them but adds no structure. See What you need to do.
Accessibility#
What it does for you#
- APG pattern: none. Prose is a styling container, not a widget.
- Deviations: none. A Prose in a Field or Fieldset is its description (see below).
- Native elements used:
<div>by default. The consumer picks<article>or<section>withas(allowed elements below), and the element's own semantics apply.
Prose is the kv-prose class as a component: a container whose headings, paragraphs, lists, links and tables the theme sets for reading. It adds no role, ARIA, text, tabindex or behaviour of its own, with one exception: inside a Field or Fieldset it is the description of the control or the group (below).
| Part | Element / role | ARIA | Notes |
|---|---|---|---|
| Prose | <div> → generic | none | class="kv-prose". Prose and ProseRoot are the same component (Prose.Root is a deprecated alias). as="article" or as="section" with aria-labelledby change the element |
| Prose | attributes | passed through | The class is its own: a className prop joins it, never replaces it. as is a string; a value outside the list is a type error and, in JavaScript, warns once in development and renders the <div>. Add kv-prose--large for the larger size |
| Prose | never | no role, aria-*, tabindex, inert | No handler, no heading, no live region, no text |
| Prose | inside a Field or Fieldset | id, data-invalid, data-disabled | It is the description: see below. The host lists its id in aria-describedby. data-invalid and data-disabled follow the host. Outside a host: none of this, no warning |
useProse() gives the same rootProps (only className) for your own element.
It announces nothing.
What you need to do#
- The content's semantics. Real headings in order, real lists, links that say where they go, tables with headers (1.3.1 Info and Relationships (A), 2.4.4 Link Purpose (In Context) (A)). Prose styles what is there. It doesn't add structure.
- Content from a CMS or Markdown needs the same checks before it is rendered.
- A description in a Field or Fieldset is short plain text. Don't put a heading, list, table or link in it: the accessible description keeps only the text. Put such a Prose outside the Field.
- Language. Text in another language goes in a nested
KvirnProvider, withuseLocale().localePropson your own element (3.1.2 Language of Parts (AA)). - Size and colour choices.
kv-prose--smallonly for notes and metadata, and the contrast of any--kv-prose-color-*colour you override (see Sizes, width and colour roles).
Warning: Don't forget
Prose styles your text but adds no structure. Use real headings in order, real lists, and links that say where they go (1.3.1 Info and Relationships, 2.4.4 Link Purpose (In Context)). Check text from a CMS or Markdown the same way.
Visual and modes#
Headless: Prose ships no CSS. With the default theme the kv-prose rules apply:
- Line length and type. A 70-character line length, and the body and heading type styles.
h1toh6each have their own style, in falling order fromh4toh6, andh4toh6do not change with the prose size. - Links. A link has an underline on hover and a focus ring.
- Contrast. Text, links and code on the page and section backgrounds are checked automatically (1.4.3 Contrast (Minimum) (AA), 1.4.11 Non-text Contrast (AA)).
- Reflow. Nothing has a fixed size, so text reflows (1.4.10 Reflow, AA): the reflow sweep runs every story at 320 CSS px and fails on horizontal overflow.
- Text spacing. The text-spacing sweep applies the 1.4.12 spacing to every story and fails on a box that clips its content (1.4.12 Text Spacing (AA)).
- Reduced motion. Prose animates only a link's colour, and only when motion is allowed.
Focus management#
- Initial focus: not moved. Prose never moves focus.
- Trap: no.
- Restore to: not applicable.
- Never obscured by: Prose renders no overlay and sets no
overflow, so a link's focus ring inside it is never clipped (2.4.11 Focus Not Obscured (Minimum) (AA)).
Sizes, width and colour roles#
With the theme, kv-prose--small, the default, kv-prose--large, kv-prose--xl and kv-prose--2xl are token swaps that grow in that order, and kv-prose--xl and --2xl step down to the large size below 40rem. kv-prose--full removes the 70ch measure. The text stays in rem and the line height has no fixed height, so it resizes to 200% (1.4.4 Resize Text (AA)) and the text-spacing overrides fit (1.4.12 Text Spacing (AA)). The --kv-prose-color-* roles recolour one part and default to the theme's tokens, so each theme, the high-contrast themes and forced colours still apply.
kv-prose--smallis for notes and metadata only. The design system keeps essential content at the default body size or larger, so a resident's instructions are never--small. Nothing enforces this: it is a consumer responsibility.- Headings keep their roles in every size.
h1toh6keep their own heading styles whatever the prose size.h4toh6never go below the default body size (essential content is never smaller) and are told apart by size, weight and letter spacing, h4 largest and h6 smallest, so in--large,--xland--2xlthey are smaller than the body text. Stop ath3in resident-facing text. Nothing enforces this: it is a consumer responsibility. - A colour you set is yours to check. The automatic contrast check measures the default colours, not an override: text and links 4.5:1, a quote bar or rule 3:1 against the surface it sits on, in every theme you ship (1.4.3 Contrast (Minimum), 1.4.11 Non-text Contrast).
- Not carried from the typography plugin: generated backticks and quote marks (generated content is read inconsistently), italics on a quote, and a scrolling
pre(a scroller a keyboard user can't reach).
A Prose in a Field or Fieldset is its description#
A Prose inside a Field.Root or a Fieldset.Root registers itself with the nearest one, like Field.ErrorMessage does, and is the description of that control or group (above the control). The help text is a different part, Field.HelpText, under the control; field.a11y.md owns it. Inside a host it is written Field.Prose or Fieldset.Prose (the same behaviour under the host's name; CheckboxGroup.Prose and RadioGroup.Prose are the group forms). There is no Field.Description or Fieldset.Description.
- Registration is automatic and has no opt-out. The control's (or group's)
aria-describedbylists every registered Prose in DOM order, each with its own id, then the error. The id is listed only while the Prose is rendered (prose.test.tsx › a Prose in a Field registers its id and the control’s aria-describedby lists it,prose.test.tsx › two Proses are listed in DOM order, then the error,prose.test.tsx › a Prose in a Fieldset describes the group). - The nearest host wins. A Prose in a Field that is inside a Fieldset describes that Field's control, not the group (
prose.test.tsx › a Prose in a Field inside a Fieldset describes the Field’s control, not the group). - The description is the Prose's text content. A heading, list, table or link inside it is read as plain text, without its role or structure, and a link in it can't be followed from the description (
prose.test.tsx › the description is its text content: a heading, list and link inside lose their structure). So keep a description to plain text and a few short paragraphs. - A Prose that isn't a description goes outside the Field or Fieldset. Every Prose inside a host registers.
- State and props. The host's
data-invalidanddata-disabledare on the Prose. The consumer'sref,classNameand other props are kept. Theidis the host's: anidof your own gives a dev warning frommergePropsand the host's wins (prose.test.tsx › invalid and disabled: …,prose.test.tsx › keeps the consumer’s ref next to the registration). - Outside a host a Prose has no id, no
data-*and no warning (prose.test.tsx › a Prose outside a Field or Fieldset has no id and does not warn). - Element. A
<div>by default, so a description can hold several paragraphs. A<p>is not allowed, because Prose holds block content: for a one-line description, write the<p>inside the Prose.
Content classes: inset, steps, figure, video and audio#
Two theme classes for CMS content. Neither is a component, adds a role, or needs a string. Neither is a focusable part, so the Keyboard section below is unchanged.
kv-inset: any block, usually<div>; no role, no ARIA, not a live region. Notaside(a landmark), notrole="note", notrole="status": it is static article content, never announced (4.1.3 does not apply). Test:prose.test.tsx › kv-inset adds no role, no live region and no tab stop, and its text stays in the reading order.kv-steps: native<ol>. Keeps thelistrole with nlistitems (Chromium); the WebKit list role and the marker being read are not proven by a test: test it with your own assistive technology. The number is the native::marker, neverlist-style: none, so WebKit keeps the list too. Noaria-current, notabindex. Test:prose.test.tsx › ol.kv-steps keeps the list role with one listitem per step, and no ARIA of its own.figure: nativefigure, named byfigcaption. No class: prose already styles it. Test:prose.test.tsx › an article with an inset, steps and a figure with alt text has no axe violations.
Consumer responsibilities for these (nothing enforces them):
- Inset. Start it with a word that says why it is set apart ("Important:", "Note:") or a heading that states the point, never a bare "Important" heading. The bar and the fill are not read aloud, and colour is never the only cue (1.3.1 Info and Relationships (A), 1.4.1 Use of Color (A)). A heading inside keeps the page's heading order (2.4.6 Headings and Labels (AA)). On a Section with the same background colour as the inset's fill, only the bar and the leading word set it apart.
- Inset, Alert or blockquote. Content that is part of the article and must not be missed (a condition, an exception, a tip) is
kv-inset. A legal or money consequence, or a deadline you lose rights by missing ("Apply by 30 April, or the application will not be processed"), is a staticAlert.Warning. The state of something (saved, failed) is an Alert, announced only when it appears after an action. A quotation is ablockquote. - Steps or Stepper.
kv-stepsis content: all the steps of a process, about 3 to 8, each a heading plus text (every step has a heading or none; headings start with a verb and do not repeat the number). The Stepper is a caption above a form question with the user's current step. They share no markup, class or string. Do not usekv-stepsas a progress indicator. A short list of one-line instructions stays a plain proseol. - Alt text (1.1.1 Non-text Content (A), 1.4.5 Images of Text (AA)). Informative photo: what it shows that matters here, about 150 characters at most; credit and source in the
figcaption. Map, chart or plan: a shortalt(what and where), and the facts in the body text or a table right after it, never only intitle. Image of text: avoid, else all the text inaltand in HTML. Decorative:alt="", nofigure, no caption. Linked image: the link's destination.altandfigcaptionare both read, so they never repeat each other. Text in another language getslang(3.1.2 Language of Parts (AA)). - Video and audio: guidance only, no component. Native
<video controls preload="metadata" playsinline>, self-hosted, with a<track kind="captions" srclang default>per language and aposter(1.2.2 Captions (Prerecorded) (A)). Neverautoplay(1.4.2 Audio Control (A), 2.2.2 Pause, Stop, Hide (A)). No YouTube, Vimeo or other iframe (no third-party network calls). Information that is only visual is spoken in the narration, or an audio-described version or a transcript with the descriptions sits next to the video (1.2.3 Audio Description or Media Alternative (Prerecorded) (A), 1.2.5 Audio Description (Prerecorded) (AA)).<audio controls>gets a transcript (1.2.1 Audio-only and Video-only (Prerecorded) (A)). Keyboard support of native media controls differs per browser: test the controls with your own assistive technology. - Not styled. Native
detailsandsummaryare not styled in prose. Closeddetailscontent does not print: do not put the only copy of a fact there.
Allowed elements#
A tag outside the list changes the page's outline or semantics (1.3.1 Info and Relationships (A), 4.1.2 Name, Role, Value (A)). as is a string, so it works from a Server Component.
| Part | `as` | Why |
|---|---|---|
| Prose | div (default), article, section | A self-contained piece or a named region around text. No p (Prose holds headings, lists and tables, which a paragraph can't contain), no landmark other than a named section |
WCAG success criteria#
- 1.3.1 Info and Relationships (A): Prose has no role of its own, so the content you write decides the semantics (
prose.test.tsx). In a Field or Fieldset the description is part of the accessible description of the control or group (prose.test.tsx, axe in both).kv-stepsis a native list. - 3.3.2 Labels or Instructions (A): a description in a Field is linked to its control.
- 1.4.3 Contrast (Minimum) (AA), 1.4.10 Reflow (AA) and 1.4.12 Text Spacing (AA): the
kv-prosetheme rules, as checked by the display-mode sweeps and by stories for the sizes and the width option. The default colours are checked by the automatic contrast check. - 1.4.4 Resize Text (AA): the sizes are in rem.
- 1.1.1 Non-text Content (A), 1.2.1 Audio-only and Video-only (Prerecorded) (A), 1.2.2 Captions (Prerecorded) (A), 1.2.3 Audio Description or Media Alternative (Prerecorded) (A), 1.2.5 Audio Description (Prerecorded) (AA), 1.4.1 Use of Color (A) and 1.4.5 Images of Text (AA): the figure, video and audio guidance and the inset's leading word. These are consumer responsibilities (see What you need to do).
Keyboard#
Prose has no keys of its own. What you put in it keeps its own keys.
API reference#
import { Prose, useProse } from '@kvirn-ui/react'Prose
Renders <div class="kv-prose"> with no role. It takes every attribute of a <div> and passes ref to it. ProseRoot is the same component, and Prose.Root is a deprecated alias. In a Field or Fieldset write Field.Prose or Fieldset.Prose. The default theme is described on Theming.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | – | Your own classes. They join kv-prose and never replace it, so the theme keeps styling the text. Add a size class here, such as kv-prose--large. |
as | 'div' | 'article' | 'section' | 'div' | Changes the element: article for a self-contained piece, or section with aria-labelledby for a named region. Prose adds no role. |
ref | Ref<HTMLElement> | – | Reaches the element, whichever it is. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-prose | always | The part class. Your className joins it. |
kv-prose--small | class you add | 14px text. Only for notes and metadata, never for essential content. Theme option. |
kv-prose--large | class you add | 18px text for long resident-facing reading. Theme option. |
kv-prose--xl | class you add | 20px text, 18px below 40rem. Theme option. |
kv-prose--2xl | class you add | 24px text, 18px below 40rem. Theme option. |
kv-prose--full | class you add | Removes the 70ch line length. Theme option. |
id | generated, in a Field or Fieldset only | The description’s id, which the control or group lists in aria-describedby. |
data-invalid | present or absent, in a Field or Fieldset only | The host is invalid. |
data-disabled | present or absent, in a Field or Fieldset only | The host is disabled. |
useProse
Takes no options. Use it when you can’t use as, for example on a component of your own. It returns the same props for every call.
Result
| Prop | Type | Default | Description |
|---|---|---|---|
rootProps | ProsePartProps | – | Spread on your element. It is only the class: { className: "kv-prose" }. |
Testing#
The automated tests prove the keyboard behaviour, the names and states, that axe finds no violations in every story and theme, and, for the components they cover, that the stories hold up in forced colours, reduced motion, text spacing and a 320 pixel width. An Automated row passes on these tests alone. A Core or Release row passes only when an automated agent check and a person on the real assistive technology have both checked it. "agent-verified" means automated tests in the repository (with a virtual screen reader for the screen reader rows), not the real assistive technology.
| AT + browser + OS | Agent check | Human check | Result | Notes |
|---|---|---|---|---|
| Automated (re-runnable tests) | ||||
| axe, WCAG 2.2 A and AA, every story, 4 themes | pass | n/a | pass | prose.stories.tsx, every story, 4 themes |
| Markup and ARIA (roles, names, ids, states) | pass | n/a | pass | prose.test.tsx › renders one element with the kv-prose class, no role or ARIA, and its children; expectNoA11yViolations |
| Keyboard contract rows (Vitest browser) | n/a | n/a | n/a | no focusable or operable part; prose renders no tabindex |
| Focus order and management | n/a | n/a | n/a | nothing focusable: the component never takes or moves focus |
| Display modes (forced colours, 320px reflow, text spacing, reduced motion) | pass | n/a | pass | the four sweep projects (storybook-forced-colors, -reduced-motion, -reflow, -text-spacing), run in CI |
| Core (required for beta) | ||||
| NVDA + Chrome + Windows | pending | pending | pending | |
| VoiceOver + Safari + iOS | pending | pending | pending | |
| Release (before 1.0 and each minor) | ||||
| JAWS + Chrome + Windows | pending | pending | pending | |
| TalkBack + Chrome + Android | pending | pending | pending | |
| VoiceOver + Safari + macOS | pending | pending | pending |
What to check#
With a screen reader and the keyboard, try:
- A description in a Field is read with the control, before the error.
- A numbered list of steps says "list, n items".
- A picture is read as its alt text, then its caption, with no repeat.