<!-- generated by scripts/gen-docs.mjs from docs/system/source-line.md. Edit the source and rerun. -->
# SourceLine

## Description
Says where the figures on screen came from and when they were read, so a reader can check them against the original.

`import { SourceLine, sourceLineLabels, type SourceRef } from "@/components/cobalt/ui/source-line"`, source `registry/cobalt/ui/source-line.tsx`, status `ready`.
Foundation: `hand-rolled`. Traps checked: `trap/link-cue`, `trap/tooltip-essential`, `trap/empty-value`, `trap/numbers-shift`, `trap/demo-on-timers`, `trap/focus-ring-shape`, `trap/external-glyph-internal` (n/a: there is no glyph; a link that opens a new tab says so in words to a screen reader).

`trap/link-cue` is answered by an underline at rest, 4px under the name, since against the muted words around it the accent ink alone measured 1.01:1 in light and 1.19:1 in dark (Accessibility). `trap/tooltip-essential` by the visible words: the time is shown and read as words such as "5 minutes ago", and the tooltip only repeats it as a full date and time, which the hover, the Tab key and a tap all reach, and which a screen reader hears as the time's description (ARIA). `trap/empty-value` by `labels.unknownTime`, "at an unknown time", for a time that is not a date, and by leaving out a `filed` or `asOf` that does not parse together with its word (States). `trap/numbers-shift` by RelativeTime's `tabular-nums` and `whitespace-nowrap`, so a tick changes the digits in place. `trap/demo-on-timers` by examples that pass fixed days for the filings and, for the time, an instant counted back from the first render (Example files). `trap/focus-ring-shape` by the system outline on each link and on the time, 2px wide and 2px off their corners (Accessibility).

The full date and time of the update once showed only to a pointer. The time is now RelativeTime with `focusable`: a tab stop whose system Tooltip opens on keyboard focus, as an icon button's does, toggles on a tap and closes on a tap elsewhere or Escape, and names the full date to a screen reader through `aria-describedby` (measured on /components/source-line: Tab from the source's link opened "Saturday, October 17, 2026 at 8:24 AM" at 1440, Escape closed it, and at 390 on a touch screen a tap opened it and a second tap closed it, with no ring; the line kept its box throughout).

### Foundation
Not applicable: hand-rolled.

| Given by the foundation | Added by the team |
|---|---|
| Not applicable: hand-rolled, a `p` built from the system's `TextLink` and `RelativeTime` | One line in `text-xs` and `--muted-foreground`: "From", then each source's name, linked to the original in a new tab with `rel="noopener noreferrer"` and "(opens in a new tab)" for a screen reader, or in the ink when it has no link; "filed {date}" and "as of {date}" through `date()` from `@/lib/cobalt/format`, in `locale`, with a date that does not parse left out together with its word; the link underlined at rest; two sources joined by "and", three or more by semicolons; "Updated" and a `RelativeTime` that keeps itself current and gives the full date in the system Tooltip on hover, on keyboard focus and on a tap (`focusable`), or `labels.unknownTime` when the time is not a date; a `note` as its own sentence after the rest; every word in `sourceLineLabels`, replaced through `labels`; nothing drawn when there is nothing to say. Taken from Fund Census's "Source: SEC Form ADV, filed {date}" line and its caution for each source (docs/research/2026-10-17-missing-parts.md, F17) |

## Examples
Under a fund's facts, the filing they came from, linked to the original, the day it was filed and when the page last read it.

Real uses, 0 call sites (`rg -n "<SourceLine\b" app registry --glob '!registry/cobalt/ui/*'`): the part is new, and no screen and no part of the registry draws one yet.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/source-line/default.tsx` | default | Under a fund's facts, the filing they came from, linked, the day it was filed and when the page read it |
| `docs/system/examples/source-line/default.tsx` | state:source | One source with its filing date |
| `docs/system/examples/source-line/default.tsx` | state:updated | Updated 5 minutes ago, which keeps itself current |
| `docs/system/examples/source-line/sources.tsx` | state:sources | Two filings under a table of holdings, each with the day its figures describe |
| `docs/system/examples/source-line/sources.tsx` | state:note | A caution about what the figures are, as its own sentence after the sources |
| `docs/system/examples/source-line/in-chart-card.tsx` | composition:ChartCard | Under a bar chart in its card, the search the bars come from and when it was read |

Example: Under a fund's facts, the filing they came from, linked, the day it was filed and when the page read it (`docs/system/examples/source-line/default.tsx`)

```tsx
import { DataList, DataListItem, DataListLabel, DataListValue } from "@/components/cobalt/ui/data-list";
import { SourceLine } from "@/components/cobalt/ui/source-line";

const minutesAgo = (minutes: number) => Date.now() - minutes * 60_000;

export default function Example() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-4">
      <DataList>
        <DataListItem>
          <DataListLabel>Regulatory assets</DataListLabel>
          <DataListValue>$12.5B</DataListValue>
        </DataListItem>
        <DataListItem>
          <DataListLabel>Employees</DataListLabel>
          <DataListValue>148</DataListValue>
        </DataListItem>
        <DataListItem>
          <DataListLabel>Private funds</DataListLabel>
          <DataListValue>23</DataListValue>
        </DataListItem>
      </DataList>
      <SourceLine
        source={{ name: "SEC Form ADV", href: "https://adviserinfo.sec.gov/", filed: "2026-03-03" }}
        updated={minutesAgo(5)}
      />
    </div>
  );
}
```

Example: Under a bar chart in its card, the search the bars come from and when it was read (`docs/system/examples/source-line/in-chart-card.tsx`)

```tsx
import { BarChart } from "@/components/cobalt/ui/bar-chart";
import { ChartCard } from "@/components/cobalt/ui/chart-card";
import { SourceLine } from "@/components/cobalt/ui/source-line";

// Form D filings received each quarter, by the first day of the quarter.
const filings = [
  { quarter: "2025-07-01", count: 412 },
  { quarter: "2025-10-01", count: 538 },
  { quarter: "2026-01-01", count: 466 },
  { quarter: "2026-04-01", count: 501 },
];

const series = [{ key: "count", label: "Filings", value: "count" as const }];

export default function Example() {
  return (
    <ChartCard title="Form D filings" value="501" note="Q2 2026" className="w-full max-w-md">
      <BarChart label="Form D filings by quarter" height="sm" data={filings} x="quarter" series={series} />
      <SourceLine
        source={{ name: "SEC EDGAR full-text search", href: "https://efts.sec.gov/" }}
        updated={Date.now() - 2 * 3_600_000}
        className="mt-3"
      />
    </ChartCard>
  );
}
```

## Variants
Not applicable: SourceLine has no variant prop. It writes the sources, the time and the caution it is given.

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| source | `source` is one `SourceRef` | follow its link to the original | "From" and the name, then "filed {date}" and "as of {date}" after a comma, then a period | test |
| sources | `source` is an array | follow each link | the names joined by "and" for two, and by semicolons for three or more, since their dates hold commas | test |
| unlinked | a `SourceRef` with no `href` | read the name | the name in `--foreground` with no link | by hand |
| updated | `updated` is passed | hover, Tab to or tap the time for the full date and time | "Updated" and words such as "5 minutes ago" that keep themselves current, and from 7 days on the date, such as "Oct 1" | test |
| unknown time | `updated` is not a date | read that the time is unknown | "Updated at an unknown time.", the words of `labels.unknownTime` in place of the time, with no tooltip | by hand |
| undated | `filed` or `asOf` does not parse | read the name | the date left out with its word, such as "From Form 5500." | test |
| note | `note` is passed | read it | the caution after the rest, with one space before it | test |
| empty | no `source`, `updated` or `note` | nothing | nothing; it renders no element, so it takes no room | test |

Example: One source with its filing date (`docs/system/examples/source-line/default.tsx`)

```tsx
import { DataList, DataListItem, DataListLabel, DataListValue } from "@/components/cobalt/ui/data-list";
import { SourceLine } from "@/components/cobalt/ui/source-line";

const minutesAgo = (minutes: number) => Date.now() - minutes * 60_000;

export default function Example() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-4">
      <DataList>
        <DataListItem>
          <DataListLabel>Regulatory assets</DataListLabel>
          <DataListValue>$12.5B</DataListValue>
        </DataListItem>
        <DataListItem>
          <DataListLabel>Employees</DataListLabel>
          <DataListValue>148</DataListValue>
        </DataListItem>
        <DataListItem>
          <DataListLabel>Private funds</DataListLabel>
          <DataListValue>23</DataListValue>
        </DataListItem>
      </DataList>
      <SourceLine
        source={{ name: "SEC Form ADV", href: "https://adviserinfo.sec.gov/", filed: "2026-03-03" }}
        updated={minutesAgo(5)}
      />
    </div>
  );
}
```

Example: Updated 5 minutes ago, which keeps itself current (`docs/system/examples/source-line/default.tsx`)

```tsx
import { DataList, DataListItem, DataListLabel, DataListValue } from "@/components/cobalt/ui/data-list";
import { SourceLine } from "@/components/cobalt/ui/source-line";

const minutesAgo = (minutes: number) => Date.now() - minutes * 60_000;

export default function Example() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-4">
      <DataList>
        <DataListItem>
          <DataListLabel>Regulatory assets</DataListLabel>
          <DataListValue>$12.5B</DataListValue>
        </DataListItem>
        <DataListItem>
          <DataListLabel>Employees</DataListLabel>
          <DataListValue>148</DataListValue>
        </DataListItem>
        <DataListItem>
          <DataListLabel>Private funds</DataListLabel>
          <DataListValue>23</DataListValue>
        </DataListItem>
      </DataList>
      <SourceLine
        source={{ name: "SEC Form ADV", href: "https://adviserinfo.sec.gov/", filed: "2026-03-03" }}
        updated={minutesAgo(5)}
      />
    </div>
  );
}
```

Example: Two filings under a table of holdings, each with the day its figures describe (`docs/system/examples/source-line/sources.tsx`)

```tsx
import { SourceLine } from "@/components/cobalt/ui/source-line";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/cobalt/ui/table";

const holdings = [
  { name: "Northwind Systems", shares: "1,240,000", value: "$412M" },
  { name: "Contoso Health", shares: "860,500", value: "$188M" },
  { name: "Fabrikam Energy", shares: "2,015,000", value: "$96M" },
];

export default function Example() {
  return (
    <div className="flex w-full max-w-lg flex-col gap-3">
      <Table>
        <TableHeader>
          <TableRow>
            <TableHead>Holding</TableHead>
            <TableHead align="end">Shares</TableHead>
            <TableHead align="end">Value</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {holdings.map((h) => (
            <TableRow key={h.name}>
              <TableHead scope="row">{h.name}</TableHead>
              <TableCell align="end">{h.shares}</TableCell>
              <TableCell align="end">{h.value}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
      <SourceLine
        source={[
          { name: "Form 13F", href: "https://www.sec.gov/", filed: "2026-08-14", asOf: "2026-06-30" },
          { name: "Form N-PORT", href: "https://www.sec.gov/", asOf: "2026-07-31" },
        ]}
        note="Positions are as filed for each report date and may have changed since."
      />
    </div>
  );
}
```

Example: A caution about what the figures are, as its own sentence after the sources (`docs/system/examples/source-line/sources.tsx`)

```tsx
import { SourceLine } from "@/components/cobalt/ui/source-line";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/cobalt/ui/table";

const holdings = [
  { name: "Northwind Systems", shares: "1,240,000", value: "$412M" },
  { name: "Contoso Health", shares: "860,500", value: "$188M" },
  { name: "Fabrikam Energy", shares: "2,015,000", value: "$96M" },
];

export default function Example() {
  return (
    <div className="flex w-full max-w-lg flex-col gap-3">
      <Table>
        <TableHeader>
          <TableRow>
            <TableHead>Holding</TableHead>
            <TableHead align="end">Shares</TableHead>
            <TableHead align="end">Value</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {holdings.map((h) => (
            <TableRow key={h.name}>
              <TableHead scope="row">{h.name}</TableHead>
              <TableCell align="end">{h.shares}</TableCell>
              <TableCell align="end">{h.value}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
      <SourceLine
        source={[
          { name: "Form 13F", href: "https://www.sec.gov/", filed: "2026-08-14", asOf: "2026-06-30" },
          { name: "Form N-PORT", href: "https://www.sec.gov/", asOf: "2026-07-31" },
        ]}
        note="Positions are as filed for each report date and may have changed since."
      />
    </div>
  );
}
```

### State precedence
- Source and updated: both show. The sources come first and end with a period, then "Updated" and the time.
- Updated and note: both show. The note follows the time.
- Unknown time and updated: unknown time wins. The words of `labels.unknownTime` take the place of the `time` element and its tooltip.
- Undated and source: both show. The name keeps its link, and the date that does not parse is left out with its word.
- Empty and any other state: Not applicable: any one of `source`, `updated` or `note` gives the line words, and with none of them nothing renders.

### Motion
Not applicable: no motion. The time's words change in place when a tick changes them, and its tooltip opens with Tooltip's own fade.

## Props

<!-- Props generated from registry/cobalt/ui/source-line.tsx with TypeScript by scripts/props-table.mjs -->
| Prop | Type | Default | Purpose |
|---|---|---|---|
| `className?` | `string` |  | Placement only. |
| `labels?` | `Partial<{ from: string; and: string; filed: (day: string) => string; asOf: (day: string) => string; updated: string; unknownTime: string; newTab: string; }>` |  |  |
| `locale?` | `string` | `"en-US"` |  |
| `note?` | `ReactNode` |  | A caution about the source, as one or two sentences after the rest. |
| `source?` | `SourceRef \| SourceRef[]` |  | One source or several, in the order the figures use them. |
| `updated?` | `string \| number \| Date` |  | When the page last read the figures: a Date, an ISO string or milliseconds. |

`source` is one `SourceRef` or several, in the order the figures use them. A `SourceRef` holds `name`, the source as people name it; `href`, the original, opened in a new tab; `filed`, the ISO date it was filed or published; and `asOf`, the day its figures describe when that is another day. `updated` is when the page last read the figures, as a Date, an ISO string or milliseconds. `note` is a caution of one or two sentences. `locale` sets the language of the dates, `"en-US"` by default. `labels` replaces any word in `sourceLineLabels`: `from`, `and`, `filed` and `asOf`, which take the formatted day, `updated`, `unknownTime` and `newTab`; a page in another language passes all of them. `className` is for placement only, such as `mt-3` under a chart, which in docs/system/examples/source-line/in-chart-card.tsx sets the line 12px below the axis labels (measured at 1440 and 390px).

## Usage

### When to use
- Figures from an outside source, such as a filing, fill a chart, a table or a list of facts, and a reader may want to check them.
- A view shows data read from a server, and how fresh it is matters to the reader.

### When not to use
- One moment something happened, such as when a comment was posted. Use RelativeTime instead.
- A link in running text. Use TextLink instead.
- Why one value is not there. Use MissingValue instead.

### Rules
- Follows `rule/relative-time-pass-the-instant`.
- `rule/source-line-under-the-figures`: When figures on a screen come from an outside source, put one `SourceLine` right under the chart, table or list of facts they fill, inside the same card, instead of one line at the end of the page, because the line names the source of the figures directly above it, and a page of 3 charts with their sources at the foot leaves the reader to match each figure to its source. Evidence: principle heuristic: recognition rather than recall; single use docs/system/examples/source-line/in-chart-card.tsx:20, the line inside the card under its chart. Check: review of every `SourceLine` and the element before it.
  - Don't: `<footer><SourceLine source={[adv, edgar, form13f]} /></footer>` under a page of 3 charts
  - Do: `<ChartCard title="Form D filings" value="501"><BarChart label="Form D filings by quarter" data={filings} x="quarter" series={series} /><SourceLine source={edgar} className="mt-3" /></ChartCard>`
- `rule/source-line-as-of-for-reports`: When the figures describe a day other than the filing date, such as a quarter's holdings, pass that day as `asOf` beside `filed`, because a Form 13F filed on Aug 14 describes June 30, and the filing date alone tells the reader the positions are newer than they are. Evidence: single use docs/system/examples/source-line/sources.tsx:34, a 13F filed in August for June 30; principle heuristic: match between system and the real world, as Fund Census cautions that 13F positions are as filed for the report quarter (docs/research/2026-10-17-missing-parts.md, F17). Check: review of every `SourceRef` for a report that covers a period.
  - Don't: `<SourceLine source={{ name: "Form 13F", filed: "2026-08-14" }} />`
  - Do: `<SourceLine source={{ name: "Form 13F", filed: "2026-08-14", asOf: "2026-06-30" }} />`

### Content
- Follows `rule/relative-time-no-prefix-word`.
- `rule/source-line-name-as-people-say-it`: When writing a `SourceRef`'s `name`, use the name its readers know, such as "SEC Form ADV" or "Form 13F", in at most 4 words, instead of a file name, a table name or a URL, because the name is the link's text and what the reader looks for at the source. Evidence: single use registry/cobalt/ui/source-line.tsx:11, the prop's own comment, "The source as people name it"; principle heuristic: match between system and the real world. Check: review of every `name` in a `SourceRef`.
  - Don't: `<SourceLine source={{ name: "sec_form_adv_2026q1.csv", href: "https://adviserinfo.sec.gov/" }} />`
  - Do: `<SourceLine source={{ name: "SEC Form ADV", href: "https://adviserinfo.sec.gov/", filed: "2026-03-03" }} />`
- `rule/source-line-note-is-a-sentence`: When passing `note`, write 1 or 2 whole sentences that end with a period and say what the figures leave out or how they may differ, such as "Positions are as filed for each report date and may have changed since.", instead of a label such as "Note: as filed", because the line adds the note after the rest with only a space before it, so it reads as the next sentence. Evidence: single use docs/system/examples/source-line/sources.tsx:37; principle heuristic: consistency and standards, the rest of the line is whole sentences. Check: review of every `note`.
  - Don't: `<SourceLine source={form13f} note="Note: as filed" />`
  - Do: `<SourceLine source={form13f} note="Positions are as filed for each report date and may have changed since." />`

### Anti-slop
- `rule/source-line-not-by-hand`: When writing where figures came from, render `SourceLine` instead of a `p` with "Source:" and a date formatted by hand, because `SourceLine` formats the dates in `locale`, keeps the updated time current through `RelativeTime`, and tells a screen reader that the link opens a new tab, which a line written by hand leaves out. Evidence: principle heuristic: consistency and standards; principle wcag: 3.2.5 Change on request, a link that opens a new tab says so. Check: review of every "Source:" and "Last updated" string in app code.
  - Don't: `<p className="text-xs text-muted-foreground">Source: SEC Form ADV. Last updated: {new Date().toLocaleString()}</p>`
  - Do: `<SourceLine source={{ name: "SEC Form ADV", href: "https://adviserinfo.sec.gov/", filed: "2026-03-03" }} updated={fetchedAt} />`

### Limits
Not applicable: the line is a paragraph that wraps in its host's column. Measured on docs/system/stress/source-line.tsx, one source and a time take 1 line at 448px and 2 at 272px, three sources and a caution take 3 lines at 448px and 4 at 272px, and a 62-character name with no spaces breaks inside the word at 256px with no overflow.

## Accessibility
Rests on a `p`, the system's `TextLink` and `RelativeTime`. Each linked source is one tab stop, an `a` that opens the original in a new tab, with "(opens in a new tab)" read after its name, and the system's 2px outline, 2px off its 6px corners, on keyboard focus. The time is one more tab stop after the links; focused by the Tab key it shows its full date in the tooltip and the outline, and a screen reader hears its words and then the full date, its description. The muted ink measured 5.6:1 on the page and 6.01:1 on a card in light, and 7.66:1 and 6.94:1 in dark. The link's accent ink measured 5.66:1 and 6.07:1 in light, and 9.15:1 and 8.29:1 in dark. Against the muted text around it the accent ink measured only 1.01:1 in light and 1.19:1 in dark, so the link is underlined at rest, 4px under the name, and the underline marks it (1.4.1 Use of color). Screen reader pass with VoiceOver: NEEDS REVIEW.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before the line | focuses the first linked source | the first link | by hand |
| Tab | a source's link | moves to the next linked source, then to the time, which opens its tooltip | the next link, then the time (measured) | by hand |
| Escape | the time | closes its tooltip | the time (measured) | by hand |
| Enter | a source's link | opens the original in a new tab | the new tab; in this tab the link keeps focus | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| line | paragraph | none | none | its text in reading order | test |
| linked source | link | its name and "(opens in a new tab)" from `labels.newTab`, visually hidden | `target="_blank"`, `rel="noopener noreferrer"` | the name, "opens in a new tab" and "link" | test |
| updated time | none, a `time` with `tabindex="0"` | its text | `dateTime` with the instant in ISO 8601, `aria-describedby` a hidden span with the full date | the words, such as "5 minutes ago", then the full date | test |

## Tokens
| Part | State | Token |
|---|---|---|
| line | all | `--muted-foreground` |
| linked name | rest | `--primary-ink`, underlined |
| linked name | focus-visible | `--ring`, `--line-focus`, `--focus-offset`, `--r-sm` |
| unlinked name | all | `--foreground` |
| time's tooltip | hover, focus, tap | Tooltip's `--tip`, `--tip-foreground` and `--t-press` |

## Related
- RelativeTime: one moment on its own, such as when a message was sent.
- TextLink: a link in running text.
- ChartCard: a chart in a card, with the source line under the chart.
- MissingValue: says why one figure is not there.
- Stat: a headline figure, whose `note` names its period.
