All components (283)
Inline citation
AI · InlineCitation
What it is and when to use it
The numbered citation inside a text: a small [2] that leads to its source.
When to use it
- Marking where a sentence of an answer comes from, next to
Sources. numberis the one of the source in the list;hrefis the address or theSourcesanchor (#sources-source-2);titleis the title of the source, which forms the name of the link.- On touch screens the hit area is about 28 × 47 px: two adjacent citations do not fit at 44 wide without overlapping, and spacing them further detaches the punctuation from the text. It exceeds the 24 px of WCAG 2.5.8.
When not to
- A long footnote: a paragraph of its own.
- A link inside the text:
Link.
Keyboard: Tab goes to the citation and Enter opens it.
Accessibility: the name of the link says the number and the title ("Source 2: Accessibility guide"), because a bare "2" says nothing to someone who hears the page. The press area is larger than the digit.
Fine-tuning: amset-citation and amset-citation__link.
What it looks like
Normal text needs a minimum contrast of 4.5 to 12.
Web accessibility guidew3.orgThe minimum contrast of normal text is 4.5 to 1.
<InlineCitation
number={2}
href="https://www.w3.org/WAI/standards-guidelines/wcag/"
title="Web accessibility guide"
source={{ host: "w3.org", snippet: "The minimum contrast of normal text is 4.5 to 1." }}
/>Props
Import it with import { InlineCitation } from '@amset/ui'. Required props are marked.
| Prop | Type | What it does |
|---|---|---|
hrefrequired | string | Where it goes: the source `href` or the `Sources` anchor (`#sources-source-1`). |
numberrequired | number | The number of the source in the list: 1, 2, 3… |
titlerequired | string | The title of the source, for the link name: "Source 2: Accessibility guide". Required. |
className | string | Merged with the library classes; it does not replace them. |
source | CitationSource | If given, pointing at or focusing the citation shows a card with the title, the site and the quoted fragment. |
It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.
In the test bench
Every state and variant, to try one at a time, on its page at storybook.amsetui.com:
