Citations
Numbered sources in an answer, with a preview on hover and the list under it.
Installation
npm i @uisatin/uiimport { Citation, Sources } from '@uisatin/ui/citations'About 31.2 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/citations.jsonAdds citations.tsx, hover-card.tsx and labels.tsx to components/ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The Citation component is a numbered link with a HoverCard preview of its source; Sources folds the list of sources into a pill that opens it.
| Prop | Type | Default |
|---|---|---|
Citation.index | number | — |
Citation.source | CitationSource | — |
Sources.sources | CitationSource[] | — |
Sources.defaultOpen | boolean | false |
CitationSource | { title, origin?, href?, icon?, quote? } | — |
className | string | — |
ref | Ref<HTMLAnchorElement> | — |
...props | ComponentProps<'a'>Other attributes go to <a> | — |
Accessibility
Citation is a link named "Source 2: <title>" (aria-label overrides it) that opens its source in a new tab; without href it is not focusable. Its preview is a hover card that opens on hover or focus and can’t be reached by keyboard, so keep the quote in the Sources list too. Sources is a button with aria-expanded and aria-controls over an ordered list of links; while folded, the list is hidden from the tab order and screen readers.
| Key | Action |
|---|---|
| Tab | Focusing a citation opens its preview after a short delay. |
| Esc | Closes the preview. |
| EnterorSpace | On Sources: opens or folds the list. |
Something wrong or missing on this page?
Report a problemSuggest an improvement