logoassistant-ui

Sources

Display URL sources with favicon, title, and external link.

Getting Started

Add sources

npx shadcn@latest add @assistant-ui/sources

Use in your application

Pass Sources to MessagePrimitive.Parts:

/components/assistant-ui/thread.tsx
import { Sources } from "@/components/assistant-ui/sources";

const AssistantMessage: FC = () => {
  return (
    <MessagePrimitive.Root className="...">
      <MessagePrimitive.Parts
        components={{
          Source: Sources,
        }}
      />
    </MessagePrimitive.Root>
  );
};

Variants

Use the variant prop to change the visual style.

<Source variant="default" />   // Subtle background
<Source variant="secondary" /> // Secondary color
<Source variant="outline" />   // Border only
<Source variant="ghost" />     // No background

Sizes

Use the size prop to change the size.

<Source size="sm" />      // Small
<Source size="default" /> // Default
<Source size="lg" />      // Large

Composable API

The component exports composable sub-components:

import { Source, SourceIcon, SourceTitle } from "@/components/assistant-ui/sources";

<Source href="https://example.com" className="gap-2">
  <SourceIcon url="https://example.com" className="size-4" />
  <SourceTitle className="max-w-none font-medium">Example</SourceTitle>
</Source>
ComponentDescription
SourceRoot container, renders as <a>
SourceIconFavicon with domain initial fallback
SourceTitleTruncated title text