# Citation

Link claims to their supporting sources.

## Preview

citation-preview-1.jsx

```jsx
import { useState } from "react";
import { MessageActions } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";
import {
  Citation,
  CitationList,
  CitationProvider,
} from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame wide>
      <RolloutAnswer sources={sources} />
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={true}>
      {children}
    </div>
  );
}

function RolloutAnswer({ sources }) {
  const [vote, setVote] = useState(null);
  const [notice, setNotice] = useState("");
  const share = async () => {
    try {
      if (navigator.share) {
        await navigator.share({
          text: "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        });
        setNotice("Response shared.");
      } else if (navigator.clipboard?.writeText) {
        await navigator.clipboard.writeText(
          "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        );
        setNotice("Response copied for sharing.");
      } else setNotice("Sharing is unavailable in this browser.");
    } catch (error) {
      if (!(error instanceof DOMException && error.name === "AbortError"))
        setNotice("The response could not be shared.");
    }
  };
  const download = () => {
    const url = URL.createObjectURL(
      new Blob(
        [
          "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        ],
        {
          type: "text/plain",
        },
      ),
    );
    const link = document.createElement("a");
    link.href = url;
    link.download = "rollout-response.txt";
    link.click();
    setTimeout(() => URL.revokeObjectURL(url), 0);
    setNotice("Response downloaded.");
  };
  return (
    <CitationProvider
      sources={sources}
      citationOrder={sources.map(({ id }) => id)}
    >
      <Message actor="assistant">
        <MessageContent>
          <MessageBody>
            <p>
              {"The mobile rollout starts with 10% of eligible accounts. "}
              <Citation sourceIds={["plan"]} />
            </p>
            <p>
              {
                "The launch review records one remaining owner for the support handoff. "
              }
              <Citation sourceIds={["review", "sla", "owners"]} />
            </p>
          </MessageBody>
          <MessageFooter>
            <MessageActions
              text={
                "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff."
              }
              vote={vote}
              onVote={setVote}
              onShare={() => void share()}
              onDownload={download}
              sources={<CitationList />}
            />
          </MessageFooter>
          {notice ? <p role="status">{notice}</p> : null}
        </MessageContent>
      </Message>
    </CitationProvider>
  );
}

```

## Design guidance

Put the source-title marker after the paragraph it supports. The group trigger shows a label, up to three source marks, and the total source count. Pass CitationList to MessageActions.sources to use the footer’s spacing and action order. Keep sources that were only read or attached separate from sources that support a claim.

Citation also composes inside [Activity](/ai-elements/activity#sources), beside a standalone result, or with current draft evidence in Composer. Scope its provider to the relevant response/draft. Use mode="provided" for retrieved or attached sources that have no claim anchors; use cited mode and explicit source IDs for actual support. A Sources pattern does not need another public owner, and source display does not perform retrieval.

Click pins a source preview open. Optional openOnHover uses Base UI's native hover behavior on desktop. Citation previews and grouped source previews use an arrow Popover on desktop and a bottom Drawer below 640px; the Drawer keeps Escape, focus return, and its accessible name. An open preview keeps its presentation until closed; the next opening uses the current viewport. A source preview shows one source at a time. Multiple sources expose Previous/Next; View all opens the response’s source Drawer. The built-in drawer and caller-composed drawers that already provide a title suppress the standalone CitationList section title. The provider keeps stable citation numbering and the first record for a duplicate ID. Only credential-free HTTP(S) URLs become links; unsafe or missing URLs remain readable text. Unresolved IDs keep an honest unresolved label and do not imply source evidence.

**Also known as**

Inline citation, Footnote, Sources.

Use Citation to connect a claim to a source. “Footnote” describes the reference pattern; it does not imply automatic numbering or a document footnote engine.

## Installation

```sh
npx shadcn@latest add https://ghost-ui.com/r/citation.json
```

```text
src/components/ui/citation.tsx
src/components/ui/citation.css
```

Import foundation.css once after shared tokens when using the canonical Button and Popover owners.

## Basic usage

The default marker belongs at the paragraph end. Put the grouped source action in the message footer.

```tsx
import {
  Citation,
  CitationList,
  CitationProvider,
  type SourceRecord,
} from "@/components/ui/citation";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";
import { MessageActions } from "@/components/ui/message-actions";

const sources: SourceRecord[] = [
  {
    id: "rollout-plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.example/rollout",
  },
];

const answer = "The rollout starts with 10% of accounts.";

export function CitationExample() {
  return (
    <CitationProvider sources={sources} citationOrder={["rollout-plan"]}>
      <Message actor="assistant">
        <MessageContent>
          <MessageBody>
            <p>
              {"The rollout starts with 10% of accounts. "}
              <Citation sourceIds={["rollout-plan"]} />
            </p>
          </MessageBody>
          <MessageFooter>
            <MessageActions text={answer} sources={<CitationList />} />
          </MessageFooter>
        </MessageContent>
      </Message>
    </CitationProvider>
  );
}
```

## Structures

- CitationProvider
  - Citation
  - CitationList

CitationProvider supplies source metadata and stable order. In citation mode, citationOrder reserves first-occurrence claim positions, including IDs with missing metadata; in provided mode, omit citationOrder and list returned sources without claiming they support a passage. Citation marks a claim; CitationList renders the source disclosure. When metadata is missing, the ID remains unresolved and no source or URL is invented.

## Examples

### Reference placement

#### Paragraph-end source title

The default marker displays the source title with the total count, including a single source.

citation-paragraph-end-source-title-2.jsx

```jsx
import { useState } from "react";
import { MessageActions } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";
import {
  Citation,
  CitationList,
  CitationProvider,
} from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame wide>
      <RolloutAnswer sources={sources} />
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={true}>
      {children}
    </div>
  );
}

function RolloutAnswer({ sources }) {
  const [vote, setVote] = useState(null);
  const [notice, setNotice] = useState("");
  const share = async () => {
    try {
      if (navigator.share) {
        await navigator.share({
          text: "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        });
        setNotice("Response shared.");
      } else if (navigator.clipboard?.writeText) {
        await navigator.clipboard.writeText(
          "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        );
        setNotice("Response copied for sharing.");
      } else setNotice("Sharing is unavailable in this browser.");
    } catch (error) {
      if (!(error instanceof DOMException && error.name === "AbortError"))
        setNotice("The response could not be shared.");
    }
  };
  const download = () => {
    const url = URL.createObjectURL(
      new Blob(
        [
          "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        ],
        {
          type: "text/plain",
        },
      ),
    );
    const link = document.createElement("a");
    link.href = url;
    link.download = "rollout-response.txt";
    link.click();
    setTimeout(() => URL.revokeObjectURL(url), 0);
    setNotice("Response downloaded.");
  };
  return (
    <CitationProvider
      sources={sources}
      citationOrder={sources.map(({ id }) => id)}
    >
      <Message actor="assistant">
        <MessageContent>
          <MessageBody>
            <p>
              {"The mobile rollout starts with 10% of eligible accounts. "}
              <Citation sourceIds={["plan"]} />
            </p>
            <p>
              {
                "The launch review records one remaining owner for the support handoff. "
              }
              <Citation sourceIds={["review", "sla", "owners"]} />
            </p>
          </MessageBody>
          <MessageFooter>
            <MessageActions
              text={
                "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff."
              }
              vote={vote}
              onVote={setVote}
              onShare={() => void share()}
              onDownload={download}
              sources={<CitationList />}
            />
          </MessageFooter>
          {notice ? <p role="status">{notice}</p> : null}
        </MessageContent>
      </Message>
    </CitationProvider>
  );
}

```

#### Inline source-title label

Use children to name a phrase-level source while retaining the source's full accessible name.

citation-inline-source-title-label-3.jsx

```jsx
import { Citation, CitationProvider } from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame wide>
      <CitationProvider sources={sources} citationOrder={["plan", "sla"]}>
        <p>
          {"Start with a 10% rollout "}
          <Citation placement="inline" sourceIds={["plan"]} />
          {", then confirm support coverage "}
          <Citation
            placement="inline"
            sourceIds={["sla"]}
            label="Staging support SLA"
          />
          .
        </p>
      </CitationProvider>
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={true}>
      {children}
    </div>
  );
}

```

### Label and number appearance

#### Numeric and inline references

Use appearance="numbered" with placement="inline" for an explicit reference chip. Use appearance="inline" when the number belongs in the running text like a footnote: it has no chip chrome, so it reads as a source ID rather than a count.

citation-numeric-and-inline-references-4.jsx

```jsx
import { Citation, CitationProvider } from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame>
      <CitationProvider sources={sources} citationOrder={["plan", "sla"]}>
        <p>
          {"Start with a 10% rollout "}
          <Citation
            sourceIds={["plan"]}
            appearance="numbered"
            placement="inline"
          />
          , then expand when support confirms coverage.
        </p>
        <p>
          {"The rollout plan "}
          <Citation
            sourceIds={["plan"]}
            appearance="inline"
            placement="inline"
          />
          {" and the staging support SLA "}
          <Citation
            sourceIds={["sla"]}
            appearance="inline"
            placement="inline"
          />
          {" define the review."}
        </p>
      </CitationProvider>
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={undefined}>
      {children}
    </div>
  );
}

```

### List and group disclosure

#### Response source group

Place the grouped source action in the actual MessageActions.sources slot. The preview retains response order and offers View all.

citation-response-source-group-5.jsx

```jsx
import { useState } from "react";
import { MessageActions } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";
import {
  Citation,
  CitationList,
  CitationProvider,
} from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame wide>
      <RolloutAnswer sources={sources} />
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={true}>
      {children}
    </div>
  );
}

function RolloutAnswer({ sources }) {
  const [vote, setVote] = useState(null);
  const [notice, setNotice] = useState("");
  const share = async () => {
    try {
      if (navigator.share) {
        await navigator.share({
          text: "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        });
        setNotice("Response shared.");
      } else if (navigator.clipboard?.writeText) {
        await navigator.clipboard.writeText(
          "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        );
        setNotice("Response copied for sharing.");
      } else setNotice("Sharing is unavailable in this browser.");
    } catch (error) {
      if (!(error instanceof DOMException && error.name === "AbortError"))
        setNotice("The response could not be shared.");
    }
  };
  const download = () => {
    const url = URL.createObjectURL(
      new Blob(
        [
          "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff.",
        ],
        {
          type: "text/plain",
        },
      ),
    );
    const link = document.createElement("a");
    link.href = url;
    link.download = "rollout-response.txt";
    link.click();
    setTimeout(() => URL.revokeObjectURL(url), 0);
    setNotice("Response downloaded.");
  };
  return (
    <CitationProvider
      sources={sources}
      citationOrder={sources.map(({ id }) => id)}
    >
      <Message actor="assistant">
        <MessageContent>
          <MessageBody>
            <p>
              {"The mobile rollout starts with 10% of eligible accounts. "}
              <Citation sourceIds={["plan"]} />
            </p>
            <p>
              {
                "The launch review records one remaining owner for the support handoff. "
              }
              <Citation sourceIds={["review", "sla", "owners"]} />
            </p>
          </MessageBody>
          <MessageFooter>
            <MessageActions
              text={
                "The mobile rollout starts with 10% of eligible accounts. The launch review records one remaining owner for the support handoff."
              }
              vote={vote}
              onVote={setVote}
              onShare={() => void share()}
              onDownload={download}
              sources={<CitationList />}
            />
          </MessageFooter>
          {notice ? <p role="status">{notice}</p> : null}
        </MessageContent>
      </Message>
    </CitationProvider>
  );
}

```

#### Detailed full list

Use variant="preview" when titles, locations, and snippets should stay visible, including in a caller-composed Drawer.

citation-detailed-full-list-6.jsx

```jsx
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame wide>
      <CitationProvider
        sources={sources}
        citationOrder={sources.map(({ id }) => id)}
      >
        <CitationList title="Rollout evidence" variant="preview" />
      </CitationProvider>
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={true}>
      {children}
    </div>
  );
}

```

#### Numbered list

Use variant="numbered" for a compact ordered list.

citation-numbered-list-7.jsx

```jsx
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame wide>
      <CitationProvider
        sources={sources}
        citationOrder={sources.map(({ id }) => id)}
      >
        <CitationList variant="numbered" title="Rollout references" />
      </CitationProvider>
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={true}>
      {children}
    </div>
  );
}

```

### Resolution and unknown data

#### Provided sources

Provided mode lists model-returned sources without suggesting they support a claim.

citation-provided-sources-8.jsx

```jsx
import { MessageActions } from "@/components/ui/message-actions";
import {
  Message,
  MessageBody,
  MessageContent,
  MessageFooter,
} from "@/components/ui/message";
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame wide>
      <CitationProvider mode="provided" sources={sources}>
        <Message actor="assistant">
          <MessageContent>
            <MessageBody>
              The model returned these documents with the answer.
            </MessageBody>
            <MessageFooter>
              <MessageActions
                text="The model returned these documents with the answer."
                sources={<CitationList mode="provided" />}
              />
            </MessageFooter>
          </MessageContent>
        </Message>
      </CitationProvider>
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={true}>
      {children}
    </div>
  );
}

```

#### Unresolved citation

An ID without source metadata stays visible and keeps its reserved citation number; no record or URL is fabricated.

citation-unresolved-citation-9.jsx

```jsx
import {
  Citation,
  CitationList,
  CitationProvider,
} from "@/components/ui/citation";
import { useSyncExternalStore } from "react";

export default function Example() {
  const sources = useSources();
  return (
    <DemoFrame>
      <CitationProvider sources={sources} citationOrder={["plan", "future"]}>
        <p>
          {"The plan is recorded "}
          <Citation sourceIds={["future"]} label="Unresolved source future">
            pending source
          </Citation>
          .
        </p>
        <CitationList variant="preview" />
      </CitationProvider>
    </DemoFrame>
  );
}

var subscribe = () => () => {};

var serverOrigin = () => "";

var browserOrigin = () => window.location.origin;

function useDemoSourceUrl(filename) {
  return useDemoAssetUrl(`/examples/${filename}`);
}

function useDemoAssetUrl(path) {
  const origin = useSyncExternalStore(subscribe, browserOrigin, serverOrigin);
  return origin ? new URL(path, origin).href : undefined;
}

var rolloutSources = [
  {
    id: "plan",
    type: "url",
    title: "Mobile rollout plan",
    url: "https://product.acme.co/rollout",
    domain: "product.acme.co",
    snippet: "The staged rollout starts with 10% of eligible accounts.",
  },
  {
    id: "sla",
    type: "url",
    title: "Staging support SLA",
    url: "https://support.acme.co/staging",
    domain: "support.acme.co",
    snippet: "Support coverage is on call during each rollout window.",
  },
  {
    id: "review",
    type: "document",
    title: "launch-review.pdf",
    document: {
      name: "launch-review.pdf",
      page: 4,
      location: "Open risks",
    },
    snippet: "The launch review lists unresolved owner assignments.",
    mediaType: "application/pdf",
    size: 245760,
  },
  {
    id: "drive",
    type: "document",
    title: "Rollout checklist",
    connectorName: "Drive",
    connectorType: "document",
    snippet: "The checklist tracks regional readiness.",
  },
  {
    id: "experiment",
    type: "document",
    title: "Experiment brief",
    document: {
      name: "experiment.md",
      location: "Launch criteria",
    },
    snippet:
      "Use the staged launch to compare completed first sessions before extending access.",
  },
  {
    id: "owners",
    type: "document",
    title: "Launch handoff notes",
    document: {
      name: "handoff.md",
      location: "Owner assignments",
    },
    snippet:
      "One owner still needs to confirm the support handoff before the next rollout window.",
  },
];

function useSources() {
  const planUrl = useDemoSourceUrl("mobile-rollout-plan.html");
  const slaUrl = useDemoSourceUrl("staging-support-sla.html");
  return rolloutSources.map((source) =>
    source.id === "plan"
      ? {
          ...source,
          url: planUrl,
        }
      : source.id === "sla"
        ? {
            ...source,
            url: slaUrl,
          }
        : source,
  );
}

function DemoFrame({ children, wide = false }) {
  return (
    <div className="ui-demo-stack" data-preview-wide={undefined}>
      {children}
    </div>
  );
}

```

### Custom source rendering

Citation uses [Badge](/components/badge) for source labels, grouped marks and counters. Replace the grouped trigger's leading content to supply favicons or other source marks. Keep those child badges informational; Citation owns the shared popover and View all behavior.

citation-custom-source-rendering-10.jsx

```jsx
import { FileText, PanelsTopLeft } from "lucide-react";
import { Badge, BadgeGroup } from "@/components/ui/badge";
import { CitationList, CitationProvider } from "@/components/ui/citation";
import { Skeleton } from "@/components/ui/skeleton";

export default function Example() {
  return (
    <div className="badge-response">
      <div className="badge-placeholder-copy" aria-hidden="true">
        <Skeleton animation="none" />
        <Skeleton
          animation="none"
          style={{
            width: "82%",
          }}
        />
      </div>
      <SourceFooter />
    </div>
  );
}

var labels = [
  "Product",
  "Research",
  "Q4 launch",
  "Customer voice",
  "Pricing",
  "Roadmap",
];

var overflowLabels = [
  ...labels,
  "Activation",
  "Retention",
  "Onboarding",
  "Support",
  "Accessibility",
  "Research synthesis",
];

var sources = [
  {
    id: "interviews",
    type: "url",
    title: "Low Tide at Pourville",
    domain: "airtable.com",
    snippet:
      "Customers most often mention the time it takes to reach their first useful result.",
  },
  {
    id: "notes",
    type: "url",
    title: "Usability testing notes",
    snippet: "Keep the first useful result close to the first step.",
  },
  {
    id: "review",
    type: "document",
    title: "Onboarding review.pdf",
    document: {
      name: "Onboarding review.pdf",
      page: 4,
    },
    snippet:
      "The review compares the first session across five onboarding flows.",
  },
  {
    id: "summary",
    type: "document",
    title: "Research summary",
    connectorName: "Notion",
    snippet: "Prioritize the issues that appear across interviews and testing.",
  },
];

function SourceFooter() {
  return (
    <CitationProvider
      sources={sources}
      citationOrder={sources.map((source) => source.id)}
    >
      <CitationList
        title="Sources"
        leading={
          <BadgeGroup aria-hidden="true">
            <Badge kind="object">
              <img src="/examples/item/low-tide.jpg" alt="" />
            </Badge>
            <Badge kind="object">
              <PanelsTopLeft />
            </Badge>
            <Badge kind="object">
              <FileText />
            </Badge>
            <Badge kind="object">R</Badge>
          </BadgeGroup>
        }
      />
    </CitationProvider>
  );
}

```

citation-custom-source-rendering-10.css

```css
/* apps/web/src/demos/library/badge-examples.css */
.badge-placeholder-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.badge-response {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  width: 420px;
  max-width: 100%;
}
.badge-response > .badge-placeholder-copy {
  width: 100%;
}
.badge-response p {
  margin: 0;
}

```

## API reference

CitationProvider properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| sources (required) | readonly SourceRecord[] | — | Provides source metadata. The first record for each ID owns the source identity. |
| mode | 'citations' \| 'provided' | 'citations' | Selects claim-aware citation mode or a truthful provided-source list. |
| citationOrder | readonly string[] | — | Supplies first-occurrence claim order in citations mode; missing records keep their reserved position. |
| onViewAll | (sourceId?: string) => void | — | Overrides the provider's local response Drawer and receives the active source ID when available. |

Citation properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| sourceIds (required) | readonly string[] | — | Identifies one or more sources. Duplicate IDs are removed while preserving order. |
| placement | 'end' \| 'inline' | 'end' | Marks paragraph-end or mid-paragraph placement for caller composition. |
| appearance | 'source-title' \| 'numbered' \| 'inline' | 'source-title' | Shows the source title and total count, an explicit numbered chip, or a footnote-style inline marker inside running text. |
| openOnHover | boolean | false | Also opens the preview on hover using the native Popover trigger behavior. |
| label | string | — | Sets the accessible trigger name; by default source titles and unresolved status are included. |
| children | ReactNode | — | Replaces the compact visual label while keeping the accessible source name. |

CitationList properties

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| showTitle | boolean | true | Hide the standalone list section heading when a parent already supplies the visible title. |
| leading | React.ReactNode | — | Replaces the grouped trigger’s source marks with caller-owned informational content. BadgeGroup and single-object Badges keep the same geometry as the default. |
| variant | 'grouped' \| 'preview' \| 'numbered' | 'grouped' | Shows the grouped Badge popover, full details, or a compact numbered list. |
| sourceIds | readonly string[] | — | Selects sources in display order. Omit to use provider citation order or all provided sources. |
| mode | 'citations' \| 'provided' | provider mode | Controls whether entries express claim order or only caller-provided sources. |
| title | string | — | Sets the list heading or grouped trigger label. |
| openOnHover | boolean | false | Also opens the grouped preview on hover. |
| selectedSourceId | string | — | Highlights and scrolls the matching row into view in a caller-composed Drawer. |

MessageParts source options

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| sourceList | boolean | true | Renders a grouped footer for ordered citations or provided-mode sources. Set false when composing a separate footer control. |
| sourceListVariant | CitationListVariant | 'grouped' | Selects grouped, detailed preview, or numbered legacy source-list rendering. |
