布局
Sources Sidebar
Sources sidebar with tabs and list
3
电子创新网
2026 AI 产业趋势报告
外部报告总结了行业规模、技术演进与应用场景。
"use client";
import { useMemo } from "react";
import SourcesSidebar from "@/components/composed/sources-sidebar/sources-sidebar";
import type { SourceItem } from "@/components/composed/custom-sources/utils";
export function SourcesSidebarDemo() {
const sources = useMemo<SourceItem[]>(
() => [
{
key: 1,
title: "内部知识库 - AI技术趋势",
content: "内部资料汇总了 2026 年 AI 技术的发展重点与落地方向。",
sourceType: "internal",
domain: "internal.knowledge.base",
},
{
key: 2,
title: "产品设计规范 v3.2",
content: "包含交互、视觉与组件规范,供团队统一设计语言。",
sourceType: "internal",
url: "/docs/design-system",
},
{
key: 3,
title: "2026 AI 产业趋势报告",
content: "外部报告总结了行业规模、技术演进与应用场景。",
url: "https://example.com/ai-trends",
favicon: "https://www.google.com/s2/favicons?domain=example.com&sz=16",
sourceType: "external",
domain: "example.com",
sourceName: "电子创新网",
},
],
[],
);
return (
<div className="w-[420px] rounded-lg border border-[var(--Border-border-neutral)]">
<SourcesSidebar sources={sources} />
</div>
);
}
SourcesSidebar 用于展示来源列表,支持内部/外部分组与快速切换,适合与 CustomSources 组合使用。
Overview
- 双 Tab 分类:内部来源与外部来源
- 列表展示:标题 + 摘要信息
- 可扩展:支持点击回调和自定义跳转
Quick Start
import SourcesSidebar from "@/registry/wuhan/composed/sources-sidebar/sources-sidebar";
const sources = [
{ key: 1, title: "内部知识库", content: "内部摘要", sourceType: "internal" },
{
key: 2,
title: "外部报告",
content: "外部摘要",
url: "https://example.com/report",
sourceType: "external",
domain: "example.com",
},
];
export function Example() {
return <SourcesSidebar sources={sources} />;
}Installation
Components
Primitives
- SourcesSidebarWrapper - 侧边栏容器
- SourcesSidebarTabs - Tab 容器
- SourcesSidebarTab - 单个 Tab
- SourcesSidebarClose - 关闭按钮
- SourcesSidebarList - 列表容器
- SourcesSidebarListItem - 列表项容器
- SourcesSidebarListItemHeader - 列表项头部
- SourcesSidebarListItemNumber - 序号
- SourcesSidebarListItemSiteInfo - 站点信息容器
- SourcesSidebarListItemLogo - 站点图标
- SourcesSidebarListItemSiteName - 站点名称
- SourcesSidebarListItemTitle - 标题
- SourcesSidebarListItemDescription - 描述
API (Composed)
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
sources | SourceItem[] | - | 来源数据列表 |
initialTab | "external" | "internal" | - | 初始 Tab |
onClose | () => void | - | 关闭回调 |
onItemClick | (source: SourceItem) => void | - | 点击列表项回调 |