Overview
Reference usage
Citation pairs an inline source marker with a Popover of source details. Every source is one row of one list, in the order given, however many there are; there is no pager.
Each row shows the source's title (clamped to two lines), its domain in small muted text under it, and its excerpt in quotation marks when it has one. With a safe web address the whole row is the link and an open-in-new glyph ends it. Without an address the row is not a link and its muted line reads "Internal document, no public link"; with a refused address it reads "Link hidden: the address isn't a safe web link". resolveCitationLink applies the same policy for a host that draws sources itself. Pass labels to translate the words Citation draws.
The panel is as tall as its rows up to about half the viewport, then the list scrolls; on a phone it opens as a bottom sheet. Pass current (an index into sources) when the reader followed a marker for one source: that row is marked, announced as current with aria-current, and scrolled into view when the list opens, so a marker in the text opens the same list as any other. Pass inPlace to open the list under the marker on a viewport at least as wide as a phone instead of in a floating popover; expanded and onExpandedChange drive that state; on a phone the sheet is used and they are not. markerLabel names a marker whose children already say how many sources there are.
Usage
When to use
- Attaching sources to an inline claim or generated answer.
- Building a full bibliography page.
Examples
Citation
Attach a compact source marker to a claim and expose its sources.
Props
Name | Type | Default | Description |
|---|---|---|---|
sources | CitationSource[] | [] | The sources behind the claim, in the order to show them. Every source is one row of one list, however many there are. |
label | text | 'Sources' | Names the marker and the panel, such as Sources. The marker reads it with the source count. |
labels | {
/** The note on a source with no address. Defaults to "Internal document, no public link". */
noLink?: string | undefined;
/** The note on a source whos… Show full type{
/** The note on a source with no address. Defaults to "Internal document, no public link". */
noLink?: string | undefined;
/** The note on a source whose address is not a safe web link. Defaults to "Link hidden: the address isn't a safe web link". */
unsafeLink?: string | undefined;
/** The marker's name when there is no source, after `label`. Defaults to "no sources". */
noSources?: string | undefined;
} | The words Citation draws itself, for a host that translates them. Each one left out keeps its English default. | |
markerLabel | text | The marker's accessible name when it has sources, for a marker whose children already say how many ("3 sources"). Defaults to label and the count, such as "Sources (3)". | |
chip | boolean | false | Draws the marker as a chip: a soft accent pill on the text line whose label ends in an ellipsis inside the pill when it is longer than the chip. Without it the marker is plain accent text. |
current | number | The index in sources of the source the reader followed a marker for. Its row is marked as the current one, and the list opens scrolled to it. | |
inPlace | boolean | false | Opens the sources under the marker instead of in a floating popover, on a viewport at least as wide as a phone. On a phone they still open in the bottom sheet. |
expanded bindable | boolean | false | With inPlace, whether the sources are open under the marker. Bindable; the marker toggles it. |
onExpandedChange | ((expanded: boolean) => void)undefined | With inPlace, called after the marker toggles expanded, with the new value. | |
closeOnSourceRemoval | boolean | false | Closes an open panel when a previously displayed source is withdrawn by the host. |
onCloseComplete | (() => void) | undefined | Called after an open source panel or sheet has fully closed. | |
children | snippet |