When to use it#
- Use it for the contact details of the page, or of the article around it: who runs the service, where to visit, how to phone or write.
- Put a phone number or email address in a Link whose text is the number or the address.
- Label each address in words. A visiting address and a postal address go in separate
Addresselements. - Put a heading above an
Address, not inside it. The HTML standard does not allow headings in it. - Not for text that only looks like an address, such as a place in a news story: use a paragraph. Not for an address the user types: use an AddressInput. Not for an address the service holds: use a DefinitionList.
Example#
import { Address, Link } from '@kvirn-ui/react'
import { useAddressTexts } from './texts.ts'
export function DefaultAddress() {
const { texts } = useAddressTexts()
return (
<Address>
{texts.organisation}
<br />
{texts.street}
<br />
{texts.postalCity}
<br />
<Link href={texts.phoneHref}>{texts.phone}</Link>
<br />
<Link href={texts.emailHref}>{texts.email}</Link>
</Address>
)
}Use cases#
A visiting address and a postal address
Residents visit one address and post to another. Give each its own Address and start it with a label.
Kvirnby municipality
Storgatan 1
123 45 KvirnbyPostal address
Kvirnby municipality
Registry office
Box 100
123 45 Kvirnby
import { Address, Stack } from '@kvirn-ui/react'
import { useAddressTexts } from './texts.ts'
export function TwoAddresses() {
const { texts } = useAddressTexts()
return (
<Stack>
<Address>
<strong>{texts.visitingLabel}</strong>
<br />
{texts.organisation}
<br />
{texts.street}
<br />
{texts.postalCity}
</Address>
<Address>
<strong>{texts.postalLabel}</strong>
<br />
{texts.organisation}
<br />
{texts.registry}
<br />
{texts.box}
<br />
{texts.postalCity}
</Address>
</Stack>
)
}Warning: Don't forget
Name each address in words, not by position or colour. Someone who hears the page read aloud gets no layout (1.3.3 Sensory Characteristics).
Who to ask about one news item
An Address inside an article is the contact for that article, not for the page.
The recycling centre has new opening hours
From 1 November the recycling centre is open until 19:00 on weekdays. On Saturdays it closes at 15:00.
Questions about this news itemEnvironment office
+46 70 174 06 05
contact@kvirnby.example
import { Address, Heading, Link } from '@kvirn-ui/react'
import { useId } from 'react'
import { useAddressTexts } from './texts.ts'
export function ArticleContact() {
const { texts } = useAddressTexts()
const headingId = useId()
return (
<article aria-labelledby={headingId} className="kv-prose">
<Heading as="h4" id={headingId}>
{texts.articleHeading}
</Heading>
<p>{texts.articleText}</p>
<Address>
<strong>{texts.articleContactLabel}</strong>
<br />
{texts.articleOffice}
<br />
<Link href={texts.phoneHref}>{texts.phone}</Link>
<br />
<Link href={texts.emailHref}>{texts.email}</Link>
</Address>
</article>
)
}Accessibility#
What it does for you#
- APG pattern: none. Address is static content, not a widget.
- Deviations: none
- Native elements used:
<address>. Noas: the element is the semantics.
Address is the native <address> element with a class, so the theme can undo the browser's italic. It adds no role, ARIA, text or behaviour. <address> has the group role in some browsers and none in others, and a screen reader reads its text as part of the page.
| Part | Element / role | ARIA | Notes |
|---|---|---|---|
| Address | <address> → native semantics | none | class="kv-address". Attributes (id, aria-*) and the ref reach the element unchanged. Links inside it are ordinary links with their own text |
| Address | never | no role, tabindex, name | It needs no accessible name: a screen reader reads its content in the flow. Don't add aria-label, which address doesn't reliably expose |
It announces nothing.
What you need to do#
- Use it for contact details of the page or the article around it only (1.3.1). Other postal-looking text is plain text.
- Say what each address is. Separate a visiting address and a postal address, with a label in words, never by position or colour alone (1.3.3).
- Link text names the target. A
tel:link has the number as its text and amailto:link has the email address, so the link makes sense out of context (2.4.4). - Language. Text in another language goes in a nested
KvirnProvider, withuseLocale().localePropson your own element (3.1.2).
Warning: Don't forget
Give each phone and email link the number or the address as its text. Then the link’s purpose is clear from the link and its surrounding text (2.4.4 Link Purpose, In Context).
Visual and modes#
Headless: Address ships no CSS. With @kvirn-ui/theme/theme.css, kv-address shows the address in upright text at the body text size and line height. Browsers set address in italic, and long italic text is harder to read, so the theme undoes it. Sizes are in rem (1.4.4). Target size and focus indicator belong to the links inside. Motion: none.
Focus management#
- Initial focus: not moved. Address never moves focus.
- Trap: no.
- Restore to: not applicable.
WCAG success criteria#
- 1.3.1 Info and Relationships: contact details are marked up as
<address>(address.test.tsx › renders an address element…). - 1.4.4 Resize Text: the size is in rem.
Keyboard#
Address has no keys of its own. What you put in it keeps its own keys.
API reference#
import { Address } from '@kvirn-ui/react'Address
Renders <address> with no role of its own. It takes every attribute of an <address> and passes ref to it. It has no state, no hook and no as, and it renders on the server too. The default theme is described on Theming.
| Prop | Type | Default | Description |
|---|---|---|---|
ref | Ref<HTMLElement> | – | Reaches the <address> element. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-address | always | The part class. The default theme uses it to undo the browser’s italic. Your className joins it. |
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 | address.stories.tsx, every story, 4 themes |
| Markup and ARIA (roles, names, ids, states) | pending | n/a | pending | address.test.tsx has no axe check |
| Keyboard contract rows (Vitest browser) | pass | n/a | pass | 2 rows, each names a test in address.test.tsx |
| Focus order and management | n/a | n/a | n/a | Address itself is never focusable and never moves focus; links inside are the consumer’s own Link components, each under its own contract |
| 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 | n/a | n/a | n/a | native <address> with its own semantics; no role, state, focus or key handling; links inside are the consumer's own Link components, each under its own contract; nothing to operate |
| VoiceOver + Safari + iOS | n/a | n/a | n/a | native <address> with its own semantics; no role, state, focus or key handling; links inside are the consumer's own Link components, each under its own contract; nothing to operate |
| Release (before 1.0 and each minor) | ||||
| JAWS + Chrome + Windows | n/a | n/a | n/a | native <address> with its own semantics; no role, state, focus or key handling; links inside are the consumer's own Link components, each under its own contract; nothing to operate |
| TalkBack + Chrome + Android | n/a | n/a | n/a | native <address> with its own semantics; no role, state, focus or key handling; links inside are the consumer's own Link components, each under its own contract; nothing to operate |
| VoiceOver + Safari + macOS | n/a | n/a | n/a | native <address> with its own semantics; no role, state, focus or key handling; links inside are the consumer's own Link components, each under its own contract; nothing to operate |