Skip to main content
Urbicon UI

CitationChipexperimental

A compact chip that marks a citation. Clicking opens a popover with the source title, snippet, and a policy-checked link. StreamingMarkdown creates these chips from its sources prop, or use CitationChip on its own for a reference list.

Playground

Style
<script lang="ts">
  import { CitationChip } from '@urbicon-ui/blocks';

  const source = { id: '1', title: 'Attention Is All You Need', url: 'https://arxiv.org/abs/1706.03762', snippet: 'We propose the Transformer, a network architecture based solely on attention mechanisms.' };
</script>

<CitationChip
  {source}
  index={1}
/>

01 Examples

Standalone source footer

Use CitationChip on its own for a reference list under an answer or card. Each chip opens a popover with the source title, snippet, and a policy-checked link.
Sources:
<script lang="ts">
  import { CitationChip, type CitationSource } from '@urbicon-ui/blocks';

  // Standalone reference list — no streamed message required. Each chip opens a
  // popover with the title, snippet, and a policy-checked outbound link.
  const sources: CitationSource[] = [
    {
      id: '1',
      title: 'Attention Is All You Need',
      url: 'https://arxiv.org/abs/1706.03762',
      snippet: 'The Transformer, based solely on attention mechanisms.'
    },
    {
      id: '2',
      title: 'Scaling Laws for Neural Language Models',
      url: 'https://arxiv.org/abs/2001.08361',
      snippet: 'Quality improves smoothly with model size, dataset size, and compute.'
    },
    {
      id: '3',
      title: 'Training language models to follow instructions',
      url: 'https://arxiv.org/abs/2203.02155',
      snippet: 'Human feedback aligns models with user intent.'
    }
  ];
</script>

<div class="flex flex-wrap items-center gap-2">
  <span class="text-text-tertiary text-sm">Sources:</span>
  {#each sources as source, i (source.id)}
    <CitationChip {source} index={i + 1} />
  {/each}
</div>

Numeric vs. label

citationStyle sets what the chip shows. Use numeric, a compact footnote pill, when citations are dense and inline; use label, the truncated title, for a handful of named sources in a footer or sidebar.
<script lang="ts">
  import { CitationChip, type CitationSource } from '@urbicon-ui/blocks';

  const source: CitationSource = {
    id: '1',
    title: 'Attention Is All You Need',
    url: 'https://arxiv.org/abs/1706.03762',
    snippet: 'The Transformer, based solely on attention mechanisms.'
  };
</script>

<div class="flex flex-wrap items-center gap-3">
  <!-- numeric: a compact footnote pill for dense inline citations. -->
  <CitationChip {source} index={1} citationStyle="numeric" />
  <!-- label: the (truncated) title, for named sources in a footer or sidebar. -->
  <CitationChip {source} index={1} citationStyle="label" />
</div>

From StreamingMarkdown

Inside a streamed answer you rarely construct chips by hand: StreamingMarkdown resolves each [id] marker to a CitationChip from its sources prop, 1-based in array order. See the StreamingMarkdown page for the full streaming flow.

Self-attention replaced recurrence in sequence models .

<script lang="ts">
  import { StreamingMarkdown, type CitationSource } from '@urbicon-ui/blocks';

  // In a streamed answer you rarely construct chips yourself: StreamingMarkdown
  // wires them up from its `sources` prop. Each in-text [id] marker whose id
  // matches a source becomes a CitationChip automatically.
  const sources: CitationSource[] = [
    {
      id: '1',
      title: 'Attention Is All You Need',
      url: 'https://arxiv.org/abs/1706.03762',
      snippet: 'The Transformer, based solely on attention mechanisms.'
    }
  ];

  const content = 'Self-attention replaced recurrence in sequence models [1].';
</script>

<StreamingMarkdown {content} {sources} headingLevelStart={3} />

02 Accessibility

Descriptive trigger label

A bare "[1]" tells a screen reader nothing, so the trigger's aria-label defaults to Source {index}: {title} (or Source: {title} with no index). Override it with the label prop when you need different wording.

Named popover

The chip opens a Popover; the same aria-label lands on the panel, so the opened panel carries a name. Keyboard and focus behaviour (open, close on Escape, focus return) come from the underlying Popover primitive.

Policy-checked link

The outbound link follows the same strict urlPolicy as StreamingMarkdown. If the URL is blocked or absent, the popover shows just the title and snippet with no link, so an untrusted source URL cannot introduce a dangerous scheme.

04 API Reference

11 props
11 props 1 required
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

5 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { CitationChip } from '@urbicon-ui/blocks';
import type { CitationChipProps, CitationSource } from '@urbicon-ui/blocks';