---
title: "Citations | Free React & Tailwind Agents Component | Motion UI"
canonical: "https://blacknest.dev/motion/c/agents/citations"
github_source: "https://github.com/Rkj0123/motion-ui-skill/blob/main/components/agents/citations.tsx"
install_command: "npx motion-ui-skill add citations"
dependencies: ["clsx","lucide-react","motion","react","tailwind-merge"]
category: "agents"
subcategory: "agents"
---

# Citations

> Inline citation markers paired with a collapsible, progressively rendered reference collection for grounded agent responses.

## Install

```bash
npx motion-ui-skill add citations
```

## Dependencies

- `clsx`
- `lucide-react`
- `motion`
- `react`
- `tailwind-merge`

## Usage

```tsx
"use client";

import { RotateCcw } from "lucide-react";
import { useReducedMotion } from "motion/react";
import { useEffect, useState } from "react";
import {
  Citation,
  Citations,
  type CitationItem,
} from "@/components/agents/citations";

const CITATION_ITEMS: CitationItem[] = [
  {
    id: "motion",
    title: "Motion documentation",
    domain: "motion.dev",
    url: "https://motion.dev/docs/react",
  },
  {
    id: "wai",
    title: "WAI accessibility patterns",
    domain: "w3.org",
    url: "https://www.w3.org/WAI/ARIA/apg/",
  },
  {
    id: "react",
    title: "React documentation",
    domain: "react.dev",
    url: "https://react.dev/learn",
  },
];

function CitationsDemo() {
  const reduce = useReducedMotion() ?? false;
  const [visible, setVisible] = useState(reduce ? CITATION_ITEMS.length : 0);

  useEffect(() => {
    if (reduce) return;
    const timers = CITATION_ITEMS.map((_, index) =>
      window.setTimeout(() => setVisible(index + 1), 500 + index * 700),
    );
    return () => timers.forEach(window.clearTimeout);
  }, [reduce]);

  return (
    <div className="space-y-4">
      <p className="text-sm leading-6 text-foreground/90">
        Use layout-aware motion for newly appended results{" "}
        <Citation citationId="motion" index={1} idPrefix="preview-source" /> and preserve accessible
        disclosure behavior <Citation citationId="wai" index={2} idPrefix="preview-source" /> as the list
        grows.
      </p>
      <Citations
        idPrefix="preview-source"
        citations={CITATION_ITEMS.slice(0, visible)}
        defaultOpen
      />
    </div>
  );
}

export function CitationsPreview() {
  const [run, setRun] = useState(0);

  return (
    <div className="relative h-[410px] w-full max-w-lg">
      <CitationsDemo key={run} />
      <button
        type="button"
        onClick={() => setRun((value) => value + 1)}
        className="absolute bottom-0 left-0 inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
      >
        <RotateCcw className="size-3" />
        Replay
      </button>
    </div>
  );
}
```

## API Reference

### Citation

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `citationId` | `string` | — | Yes | — |
| `index` | `number` | — | Yes | — |
| `idPrefix` | `string` | — | Yes | Must match the related Citations idPrefix. |
| `className` | `string` | — | No | — |

### CitationFavicon

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `url` | `string` | — | No | — |
| `className` | `string` | — | No | — |

### CitationStack

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `citations` | `CitationItem[]` | — | Yes | — |
| `limit` | `number` | `3` | No | — |
| `className` | `string` | — | No | — |

### CitationList

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `citations` | `CitationItem[]` | — | Yes | — |
| `idPrefix` | `string` | — | No | — |
| `className` | `string` | — | No | — |

### Citations

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `citations` | `CitationItem[]` | — | Yes | — |
| `title` | `ReactNode` | `Sources` | No | — |
| `open` | `boolean` | — | No | — |
| `defaultOpen` | `boolean` | `false` | No | — |
| `onOpenChange` | `((open: boolean) => void)` | — | No | — |
| `idPrefix` | `string` | — | No | — |
| `className` | `string` | — | No | — |

## Source Files

- [components/agents/citations.tsx](https://github.com/Rkj0123/motion-ui-skill/blob/main/components/agents/citations.tsx)
- [components/agents/agent-disclosure.tsx](https://github.com/Rkj0123/motion-ui-skill/blob/main/components/agents/agent-disclosure.tsx)
- [lib/ease.ts](https://github.com/Rkj0123/motion-ui-skill/blob/main/lib/ease.ts)
- [lib/favicon.ts](https://github.com/Rkj0123/motion-ui-skill/blob/main/lib/favicon.ts)
- [lib/hooks/use-favicon.ts](https://github.com/Rkj0123/motion-ui-skill/blob/main/lib/hooks/use-favicon.ts)
- [lib/utils.ts](https://github.com/Rkj0123/motion-ui-skill/blob/main/lib/utils.ts)
