Skip to content
Mizen UI
Docs

IntroductionInstallationCLIStylingFoundationsThemingCompositionIntegrationsAccessibilityFor agents

useCopyToClipboard

AccordionAspect RatioCardCollapsibleFrameGridGroupInlineScroll AreaSectionSeparatorSpacerStack

BlockquoteCitationCodeHeadingKbdLabelLinkTextVisually Hidden

ButtonButton GroupToggleToggle groupToolbar

CalendarCheckboxCheckbox groupComboboxDate pickerDate range pickerDate-Time InputFieldFieldsetFile UploadFormInputInput groupNumber fieldOTP FieldRadio groupSelectSliderSwitchTextareaTime Input

BreadcrumbMenubarNavigation MenuPaginationSegmented ControlStepperTabs

Alert dialogCommandContext MenuDialogDrawerMenuPopoverPreview CardSheetTooltip

AlertBadgeEmptyError StateMeterProgressSkeletonSpinnerStatus dotToast

Activity FeedAvatarAvatar GroupData TableListMetricOverflow ListProperty ListTableTokenTree

Area ChartBar ListCalendar HeatmapCategory ComparisonChart FrameChart LegendChart TooltipDistributionFunnelHeatmapMetric TrendPart-to-WholeProgress RingsRadar ChartRadial BarsSankey ChartScatter ChartScore GaugeTime Series

Diagram

AttachmentCarouselCode BlockLightboxMarkdownThumbnailTimestamp

Agent ThinkingApproval CardComposerConversationInline CitationMessageMessage ScrollerQuestion CardSourcesStreaming TextSuggestionTask ListTerminalTool Call

On this page

  • Preview
  • Usage
  • With the AI SDK
  • With TanStack AI
  • Examples
  • Documents
  • Recommendations
  • Usage boundaries
  • API reference

Agentic

Sources

The pages and documents an agent used for a reply, folded into one line with their favicons and a count. It opens to a link for each.

idle

Usage

import { Sources } from "@mizen-labs/ui";

With the AI SDK

Collect the reply's source-url and source-document parts. A title is optional on source-url; Sources falls back to the domain.

import { useChat } from "@ai-sdk/react";
import { Sources, type SourcesItem } from "@mizen-labs/ui";

function sourcesOf(message: { parts: { type: string }[] }): SourcesItem[] {
	return message.parts.flatMap((part) => {
		if (part.type === "source-url") {
			return [{ href: part.url, title: part.title }];
		}
		if (part.type === "source-document") {
			return [{ title: part.title }];
		}
		return [];
	});
}

export function ReplySources() {
	const { messages } = useChat();
	const reply = messages.findLast((message) => message.role === "assistant");
	// Sources drops repeats, so a page cited twice shows once.
	return reply ? <Sources sources={sourcesOf(reply)} /> : null;
}

With TanStack AI

TanStack AI has no source part. Return sources from your tool or server as data, then pass them to Sources.

import { Sources } from "@mizen-labs/ui";

// For example, from a search tool's result.
export function SearchSources({ results }: { results: { title: string; url: string }[] }) {
	return (
		<Sources
			sources={results.map((result) => ({ href: result.url, title: result.title }))}
		/>
	);
}

Examples

Documents

Files without a link show as text beside the web pages.

Recommendations

GuidancePractice
Do

Pass every source part as it arrives; Sources drops repeats. Give documents a title so they read as more than a domain.

Usage boundaries

GuidanceBoundary
Scope

The application finds and stores sources. Sources shows them; it fetches only each site's favicon.

Scope

Show sources the agent used for this reply, not every search result it saw.

API reference

Public props from @mizen-labs/ui. Use exported prop types for the complete TypeScript contract.

PropTypeDefaultDescription
sourcesreadonly { href?: string; title?: string; icon?: string }[]—The pages and documents the agent used. A link has href; a document has only a title. Repeats show once, and nothing renders without sources.
defaultOpenbooleanfalseOpens the list from the start.
PreviousQuestion CardNextStreaming Text
  • CSS container queriesdeveloper.mozilla.org, opens in a new tab
  • Container queries land in stable browsersweb.dev, opens in a new tab
  • CSS Container Queries (Size)caniuse.com, opens in a new tab