@assistant-ui/mcp-docs-server 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/with-ag-ui.md +172 -1633
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +42 -1640
- package/.docs/organized/code-examples/with-assistant-transport.md +40 -1743
- package/.docs/organized/code-examples/with-cloud.md +71 -1745
- package/.docs/organized/code-examples/with-custom-thread-list.md +87 -1723
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +70 -1637
- package/.docs/organized/code-examples/with-external-store.md +67 -1624
- package/.docs/organized/code-examples/with-ffmpeg.md +71 -1629
- package/.docs/organized/code-examples/with-langgraph.md +95 -1893
- package/.docs/organized/code-examples/with-parent-id-grouping.md +57 -1654
- package/.docs/organized/code-examples/with-react-hook-form.md +220 -2163
- package/.docs/organized/code-examples/with-react-router.md +66 -1318
- package/.docs/organized/code-examples/with-store.md +31 -31
- package/.docs/organized/code-examples/with-tanstack.md +77 -861
- package/.docs/organized/code-examples/with-tap-runtime.md +812 -0
- package/.docs/raw/docs/(docs)/cli.mdx +66 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -1
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -1
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +4 -4
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +3 -3
- package/.docs/raw/docs/(docs)/devtools.mdx +0 -1
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +2 -3
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +117 -117
- package/.docs/raw/docs/(docs)/guides/suggestions.mdx +296 -0
- package/.docs/raw/docs/(docs)/guides/tools.mdx +336 -513
- package/.docs/raw/docs/(docs)/index.mdx +33 -410
- package/.docs/raw/docs/(docs)/installation.mdx +450 -0
- package/.docs/raw/docs/(docs)/llm.mdx +209 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +48 -3
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +9 -3
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +20 -52
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +16 -39
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +49 -50
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +3 -11
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +0 -3
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +5 -16
- package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +152 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +28 -40
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +2 -3
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -1
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +5 -5
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -1
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -1
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +207 -33
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +0 -1
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +0 -1
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +0 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +0 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +118 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +198 -0
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +3 -3
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +5 -6
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -11
- package/.docs/raw/docs/runtimes/custom/local.mdx +43 -36
- package/.docs/raw/docs/runtimes/data-stream.mdx +35 -3
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +1 -2
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +0 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -1
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -1
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -1
- package/.docs/raw/docs/ui/accordion.mdx +259 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -3
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -3
- package/.docs/raw/docs/ui/attachment.mdx +0 -2
- package/.docs/raw/docs/ui/badge.mdx +138 -0
- package/.docs/raw/docs/ui/diff-viewer.mdx +279 -0
- package/.docs/raw/docs/ui/file.mdx +152 -0
- package/.docs/raw/docs/ui/image.mdx +100 -0
- package/.docs/raw/docs/ui/markdown.mdx +0 -1
- package/.docs/raw/docs/ui/mermaid.mdx +0 -1
- package/.docs/raw/docs/ui/model-selector.mdx +224 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +4 -5
- package/.docs/raw/docs/ui/reasoning.mdx +6 -5
- package/.docs/raw/docs/ui/scrollbar.mdx +26 -9
- package/.docs/raw/docs/ui/select.mdx +245 -0
- package/.docs/raw/docs/ui/sources.mdx +6 -5
- package/.docs/raw/docs/ui/streamdown.mdx +348 -0
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +8 -63
- package/.docs/raw/docs/ui/tabs.mdx +259 -0
- package/.docs/raw/docs/ui/thread-list.mdx +98 -16
- package/.docs/raw/docs/ui/thread.mdx +57 -73
- package/.docs/raw/docs/ui/tool-fallback.mdx +0 -1
- package/.docs/raw/docs/ui/tool-group.mdx +1 -3
- package/README.md +3 -3
- package/package.json +4 -4
- package/src/tools/tests/examples.test.ts +1 -1
- package/.docs/raw/docs/(docs)/about-assistantui.mdx +0 -54
- package/.docs/raw/docs/(docs)/mcp-docs-server.mdx +0 -321
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +0 -219
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Streamdown
|
|
3
|
+
description: Alternative markdown renderer with built-in syntax highlighting, math, and diagram support.
|
|
4
|
+
links:
|
|
5
|
+
- label: Streamdown
|
|
6
|
+
url: https://github.com/vercel/streamdown
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
import { PackageManagerTabs } from "@/components/docs/fumadocs/install/package-manager-tabs";
|
|
10
|
+
import { StreamdownSample } from "@/components/docs/samples/streamdown";
|
|
11
|
+
|
|
12
|
+
<StreamdownSample />
|
|
13
|
+
|
|
14
|
+
<Callout type="info">
|
|
15
|
+
`@assistant-ui/react-streamdown` is an **alternative** to `@assistant-ui/react-markdown`. Choose based on your needs:
|
|
16
|
+
- **react-markdown**: Lightweight, bring-your-own syntax highlighter
|
|
17
|
+
- **react-streamdown**: Feature-rich with built-in Shiki, KaTeX, Mermaid support
|
|
18
|
+
</Callout>
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
<PackageManagerTabs packages={["@assistant-ui/react-streamdown", "streamdown"]} />
|
|
23
|
+
|
|
24
|
+
For additional features, install the optional plugins:
|
|
25
|
+
|
|
26
|
+
<PackageManagerTabs packages={["@streamdown/code", "@streamdown/math", "@streamdown/mermaid", "@streamdown/cjk"]} />
|
|
27
|
+
|
|
28
|
+
## Basic Usage
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { StreamdownTextPrimitive } from "@assistant-ui/react-streamdown";
|
|
32
|
+
|
|
33
|
+
// Inside a MessagePrimitive.Parts component
|
|
34
|
+
<MessagePrimitive.Parts components={{ Text: StreamdownText }} />
|
|
35
|
+
|
|
36
|
+
// Where StreamdownText is:
|
|
37
|
+
const StreamdownText = () => <StreamdownTextPrimitive />;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## With Plugins (Recommended)
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { StreamdownTextPrimitive } from "@assistant-ui/react-streamdown";
|
|
44
|
+
import { code } from "@streamdown/code";
|
|
45
|
+
import { math } from "@streamdown/math";
|
|
46
|
+
import { mermaid } from "@streamdown/mermaid";
|
|
47
|
+
import "katex/dist/katex.min.css";
|
|
48
|
+
|
|
49
|
+
const StreamdownText = () => (
|
|
50
|
+
<StreamdownTextPrimitive
|
|
51
|
+
plugins={{ code, math, mermaid }}
|
|
52
|
+
shikiTheme={["github-light", "github-dark"]}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
When `@streamdown/code` is provided, the default theme is `["github-light", "github-dark"]` for light/dark mode support.
|
|
58
|
+
|
|
59
|
+
## Migration from react-markdown
|
|
60
|
+
|
|
61
|
+
If you're migrating from `@assistant-ui/react-markdown`, your existing `SyntaxHighlighter` and `CodeHeader` components still work:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { StreamdownTextPrimitive } from "@assistant-ui/react-streamdown";
|
|
65
|
+
|
|
66
|
+
const StreamdownText = () => (
|
|
67
|
+
<StreamdownTextPrimitive
|
|
68
|
+
components={{
|
|
69
|
+
SyntaxHighlighter: MySyntaxHighlighter,
|
|
70
|
+
CodeHeader: MyCodeHeader,
|
|
71
|
+
}}
|
|
72
|
+
componentsByLanguage={{
|
|
73
|
+
mermaid: { SyntaxHighlighter: MermaidRenderer }
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Props
|
|
80
|
+
|
|
81
|
+
| Prop | Type | Default | Description |
|
|
82
|
+
|------|------|---------|-------------|
|
|
83
|
+
| `mode` | `"streaming" \| "static"` | `"streaming"` | Rendering mode |
|
|
84
|
+
| `plugins` | `PluginConfig` | - | Streamdown plugins (code, math, mermaid, cjk) |
|
|
85
|
+
| `shikiTheme` | `[string, string]` | `["github-light", "github-dark"]` | Light and dark theme for Shiki |
|
|
86
|
+
| `components` | `object` | - | Custom components including `SyntaxHighlighter` and `CodeHeader` |
|
|
87
|
+
| `componentsByLanguage` | `object` | - | Language-specific component overrides |
|
|
88
|
+
| `preprocess` | `(text: string) => string` | - | Text preprocessing function |
|
|
89
|
+
| `controls` | `boolean \| object` | `true` | Enable/disable UI controls for code blocks and tables |
|
|
90
|
+
| `caret` | `"block" \| "circle"` | - | Streaming caret style |
|
|
91
|
+
| `mermaid` | `MermaidOptions` | - | Mermaid diagram configuration |
|
|
92
|
+
| `linkSafety` | `LinkSafetyConfig` | - | Link safety confirmation dialog |
|
|
93
|
+
| `remend` | `RemendConfig` | - | Incomplete markdown auto-completion |
|
|
94
|
+
| `allowedTags` | `Record<string, string[]>` | - | HTML tags whitelist |
|
|
95
|
+
| `containerProps` | `object` | - | Props for the container div |
|
|
96
|
+
| `containerClassName` | `string` | - | Class name for the container |
|
|
97
|
+
| `remarkRehypeOptions` | `object` | - | Options passed to remark-rehype |
|
|
98
|
+
| `BlockComponent` | `ComponentType` | - | Custom component for rendering blocks |
|
|
99
|
+
| `parseMarkdownIntoBlocksFn` | `(md: string) => string[]` | - | Custom block parsing function |
|
|
100
|
+
| `parseIncompleteMarkdown` | `boolean` | `false` | Parse incomplete markdown as-is (skip remend) |
|
|
101
|
+
| `security` | `SecurityConfig` | - | URL/image security restrictions |
|
|
102
|
+
|
|
103
|
+
## Plugin Configuration
|
|
104
|
+
|
|
105
|
+
### Code Highlighting
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { code } from "@streamdown/code";
|
|
109
|
+
|
|
110
|
+
<StreamdownTextPrimitive
|
|
111
|
+
plugins={{ code }}
|
|
112
|
+
shikiTheme={["github-light", "github-dark"]}
|
|
113
|
+
/>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Math (LaTeX)
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { math } from "@streamdown/math";
|
|
120
|
+
import "katex/dist/katex.min.css";
|
|
121
|
+
|
|
122
|
+
<StreamdownTextPrimitive plugins={{ math }} />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Mermaid Diagrams
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { mermaid } from "@streamdown/mermaid";
|
|
129
|
+
|
|
130
|
+
<StreamdownTextPrimitive plugins={{ mermaid }} />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### CJK Text Optimization
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { cjk } from "@streamdown/cjk";
|
|
137
|
+
|
|
138
|
+
<StreamdownTextPrimitive plugins={{ cjk }} />
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Advanced Configuration
|
|
142
|
+
|
|
143
|
+
### Mermaid Options
|
|
144
|
+
|
|
145
|
+
Customize Mermaid diagram rendering with configuration and error handling:
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { mermaid } from "@streamdown/mermaid";
|
|
149
|
+
|
|
150
|
+
<StreamdownTextPrimitive
|
|
151
|
+
plugins={{ mermaid }}
|
|
152
|
+
mermaid={{
|
|
153
|
+
config: { theme: "dark" },
|
|
154
|
+
errorComponent: ({ error, chart, retry }) => (
|
|
155
|
+
<div>
|
|
156
|
+
<p>Failed to render diagram: {error}</p>
|
|
157
|
+
<button onClick={retry}>Retry</button>
|
|
158
|
+
</div>
|
|
159
|
+
),
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Streaming Caret
|
|
165
|
+
|
|
166
|
+
Display a caret indicator during streaming:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
<StreamdownTextPrimitive caret="block" /> // ▋
|
|
170
|
+
<StreamdownTextPrimitive caret="circle" /> // ●
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Link Safety
|
|
174
|
+
|
|
175
|
+
Show confirmation before opening external links:
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
<StreamdownTextPrimitive
|
|
179
|
+
linkSafety={{
|
|
180
|
+
enabled: true,
|
|
181
|
+
onLinkCheck: (url) => url.startsWith("https://trusted.com"),
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Incomplete Markdown Handling (Remend)
|
|
187
|
+
|
|
188
|
+
Configure how incomplete markdown syntax is handled during streaming:
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<StreamdownTextPrimitive
|
|
192
|
+
remend={{
|
|
193
|
+
links: true, // Complete incomplete links
|
|
194
|
+
images: true, // Handle incomplete images
|
|
195
|
+
bold: true, // Complete **text → **text**
|
|
196
|
+
italic: true, // Complete *text → *text*
|
|
197
|
+
inlineCode: true, // Complete `code → `code`
|
|
198
|
+
katex: true, // Complete $$equation → $$equation$$
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Allowed HTML Tags
|
|
204
|
+
|
|
205
|
+
Allow specific HTML tags in markdown content:
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
<StreamdownTextPrimitive
|
|
209
|
+
allowedTags={{
|
|
210
|
+
div: ["class", "id"],
|
|
211
|
+
span: ["class", "style"],
|
|
212
|
+
iframe: ["src", "width", "height"],
|
|
213
|
+
}}
|
|
214
|
+
/>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Security Configuration
|
|
218
|
+
|
|
219
|
+
Restrict allowed URLs for links and images. This overrides streamdown's default allow-all policy:
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
<StreamdownTextPrimitive
|
|
223
|
+
security={{
|
|
224
|
+
// Only allow links to trusted domains
|
|
225
|
+
allowedLinkPrefixes: ["https://example.com", "https://docs.example.com"],
|
|
226
|
+
// Only allow images from your CDN
|
|
227
|
+
allowedImagePrefixes: ["https://cdn.example.com"],
|
|
228
|
+
// Restrict protocols
|
|
229
|
+
allowedProtocols: ["https", "mailto"],
|
|
230
|
+
// Disable base64 data images
|
|
231
|
+
allowDataImages: false,
|
|
232
|
+
// CSS class for blocked elements
|
|
233
|
+
blockedLinkClass: "blocked-link",
|
|
234
|
+
blockedImageClass: "blocked-image",
|
|
235
|
+
}}
|
|
236
|
+
/>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Detecting Inline vs Block Code
|
|
240
|
+
|
|
241
|
+
When building custom code components, you can use `useIsStreamdownCodeBlock` to detect whether you're inside a code block or inline code:
|
|
242
|
+
|
|
243
|
+
```tsx
|
|
244
|
+
import { useIsStreamdownCodeBlock } from "@assistant-ui/react-streamdown";
|
|
245
|
+
|
|
246
|
+
function MyCodeComponent({ children, ...props }) {
|
|
247
|
+
const isCodeBlock = useIsStreamdownCodeBlock();
|
|
248
|
+
|
|
249
|
+
if (!isCodeBlock) {
|
|
250
|
+
return <code className="inline-code" {...props}>{children}</code>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return <pre><code {...props}>{children}</code></pre>;
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
You can also use `useStreamdownPreProps` to access the props passed to the parent `<pre>` element:
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
import { useStreamdownPreProps } from "@assistant-ui/react-streamdown";
|
|
261
|
+
|
|
262
|
+
function MyCodeComponent({ children }) {
|
|
263
|
+
const preProps = useStreamdownPreProps();
|
|
264
|
+
|
|
265
|
+
if (!preProps) {
|
|
266
|
+
// Inline code
|
|
267
|
+
return <code>{children}</code>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Block code - preProps contains className, node, etc.
|
|
271
|
+
return <code className={preProps.className}>{children}</code>;
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Comparison with react-markdown
|
|
276
|
+
|
|
277
|
+
| Feature | react-markdown | react-streamdown |
|
|
278
|
+
|---------|---------------|------------------|
|
|
279
|
+
| Bundle size | Smaller | Larger (with plugins) |
|
|
280
|
+
| Syntax highlighting | Bring your own | Built-in Shiki |
|
|
281
|
+
| Math rendering | Manual setup | Built-in KaTeX |
|
|
282
|
+
| Mermaid diagrams | Manual setup | Built-in support |
|
|
283
|
+
| CJK optimization | None | Built-in |
|
|
284
|
+
| Streaming | `smooth` prop | `mode` + block-based |
|
|
285
|
+
|
|
286
|
+
## Re-exported Utilities
|
|
287
|
+
|
|
288
|
+
The package re-exports useful utilities:
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import {
|
|
292
|
+
// Context for accessing streamdown state
|
|
293
|
+
StreamdownContext,
|
|
294
|
+
// Parse markdown into blocks (for custom implementations)
|
|
295
|
+
parseMarkdownIntoBlocks,
|
|
296
|
+
// Hooks for custom code components
|
|
297
|
+
useIsStreamdownCodeBlock,
|
|
298
|
+
useStreamdownPreProps,
|
|
299
|
+
// Memo comparison utility for custom components
|
|
300
|
+
memoCompareNodes,
|
|
301
|
+
// Default Shiki theme: ["github-light", "github-dark"]
|
|
302
|
+
DEFAULT_SHIKI_THEME,
|
|
303
|
+
} from "@assistant-ui/react-streamdown";
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Available Types
|
|
307
|
+
|
|
308
|
+
```tsx
|
|
309
|
+
import type {
|
|
310
|
+
// Component props
|
|
311
|
+
StreamdownTextPrimitiveProps,
|
|
312
|
+
SyntaxHighlighterProps,
|
|
313
|
+
CodeHeaderProps,
|
|
314
|
+
ComponentsByLanguage,
|
|
315
|
+
StreamdownTextComponents,
|
|
316
|
+
StreamdownProps,
|
|
317
|
+
// Plugin types
|
|
318
|
+
PluginConfig,
|
|
319
|
+
ResolvedPluginConfig,
|
|
320
|
+
CodeHighlighterPlugin,
|
|
321
|
+
DiagramPlugin,
|
|
322
|
+
MathPlugin,
|
|
323
|
+
CjkPlugin,
|
|
324
|
+
HighlightOptions,
|
|
325
|
+
// Shiki types
|
|
326
|
+
BundledTheme,
|
|
327
|
+
BundledLanguage,
|
|
328
|
+
// Configuration types
|
|
329
|
+
CaretStyle,
|
|
330
|
+
ControlsConfig,
|
|
331
|
+
MermaidOptions,
|
|
332
|
+
MermaidErrorComponentProps,
|
|
333
|
+
LinkSafetyConfig,
|
|
334
|
+
LinkSafetyModalProps,
|
|
335
|
+
RemendConfig,
|
|
336
|
+
RemendHandler,
|
|
337
|
+
AllowedTags,
|
|
338
|
+
RemarkRehypeOptions,
|
|
339
|
+
BlockProps,
|
|
340
|
+
SecurityConfig,
|
|
341
|
+
} from "@assistant-ui/react-streamdown";
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Related Components
|
|
345
|
+
|
|
346
|
+
- [Markdown](/docs/ui/markdown) - Lightweight markdown with react-markdown
|
|
347
|
+
- [Syntax Highlighting](/docs/ui/syntax-highlighting) - Add code highlighting to react-markdown
|
|
348
|
+
- [Mermaid](/docs/ui/mermaid) - Render diagrams in react-markdown
|
|
@@ -3,7 +3,6 @@ title: Syntax Highlighting
|
|
|
3
3
|
description: Code block syntax highlighting with react-shiki or react-syntax-highlighter.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
7
6
|
import { SyntaxHighlightingSample } from "@/components/docs/samples/syntax-highlighting";
|
|
8
7
|
|
|
9
8
|
<SyntaxHighlightingSample />
|
|
@@ -51,68 +50,14 @@ export const defaultComponents = memoizeMarkdownComponents({
|
|
|
51
50
|
|
|
52
51
|
### Options
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"https://github.com/AVGVSTVS96/react-shiki/blob/694433ef697c9791b3816cf94d12d571e8abbb3a/package/src/types.ts#L51",
|
|
63
|
-
default: "github-dark",
|
|
64
|
-
required: true,
|
|
65
|
-
},
|
|
66
|
-
language: {
|
|
67
|
-
description:
|
|
68
|
-
"Shiki built-in or custom textmate grammar object for highlighting",
|
|
69
|
-
type: "Language (string | object)",
|
|
70
|
-
typeDescriptionLink:
|
|
71
|
-
"https://github.com/AVGVSTVS96/react-shiki/blob/694433ef697c9791b3816cf94d12d571e8abbb3a/package/src/types.ts#L24",
|
|
72
|
-
default: "text",
|
|
73
|
-
required: true,
|
|
74
|
-
},
|
|
75
|
-
as: {
|
|
76
|
-
description: "The code block container element type",
|
|
77
|
-
type: "React.ElementType",
|
|
78
|
-
default: "pre",
|
|
79
|
-
},
|
|
80
|
-
className: {
|
|
81
|
-
description: "Custom CSS classes for the code block container element",
|
|
82
|
-
type: "string",
|
|
83
|
-
default: "",
|
|
84
|
-
},
|
|
85
|
-
style: {
|
|
86
|
-
description: "Inline styles for the code block container element",
|
|
87
|
-
type: "React.CSSProperties",
|
|
88
|
-
default: undefined,
|
|
89
|
-
},
|
|
90
|
-
delay: {
|
|
91
|
-
description:
|
|
92
|
-
"Delay in milliseconds between consecutive highlights, useful for streamed code responses.",
|
|
93
|
-
type: "number",
|
|
94
|
-
default: 0,
|
|
95
|
-
},
|
|
96
|
-
customLanguages: {
|
|
97
|
-
description: "Custom languages to preload for highlighting",
|
|
98
|
-
type: "Language[]",
|
|
99
|
-
typeDescriptionLink:
|
|
100
|
-
"https://github.com/AVGVSTVS96/react-shiki/blob/694433ef697c9791b3816cf94d12d571e8abbb3a/package/src/types.ts#L24",
|
|
101
|
-
default: "",
|
|
102
|
-
},
|
|
103
|
-
codeToHastOptions: {
|
|
104
|
-
description: "All other options supported by Shiki's `codeToHast`",
|
|
105
|
-
type: "CodeToHastOptions",
|
|
106
|
-
typeDescriptionLink:
|
|
107
|
-
"https://github.com/shikijs/shiki/blob/main/packages/types/src/options.ts#L121",
|
|
108
|
-
default: "{}",
|
|
109
|
-
required: true,
|
|
110
|
-
},
|
|
111
|
-
// This reverts the order of the type table, fumadocs reversed the order on 4/22/25 in:
|
|
112
|
-
// https://github.com/fuma-nama/fumadocs/commit/3a5595aa65acfa5c20be2377d09c03fbb1de72a6
|
|
113
|
-
}).reverse(),
|
|
114
|
-
)}
|
|
115
|
-
/>
|
|
53
|
+
See [react-shiki documentation](https://github.com/AVGVSTVS96/react-shiki#props) for all available options.
|
|
54
|
+
|
|
55
|
+
Key options:
|
|
56
|
+
- `theme` - Shiki theme (default: `"github-dark"`)
|
|
57
|
+
- `language` - Language for highlighting (default: `"text"`)
|
|
58
|
+
- `delay` - Delay between highlights, useful for streaming (default: `0`)
|
|
59
|
+
- `customLanguages` - Custom languages to preload
|
|
60
|
+
- `codeToHastOptions` - Options passed to Shiki's `codeToHast`
|
|
116
61
|
|
|
117
62
|
### Bundle Optimization
|
|
118
63
|
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Tabs
|
|
3
|
+
description: A multi-variant tabs component for organizing content into switchable panels.
|
|
4
|
+
links:
|
|
5
|
+
- label: Radix UI Tabs
|
|
6
|
+
url: https://www.radix-ui.com/primitives/docs/components/tabs
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
import { PreviewCode } from "@/components/docs/preview-code.server";
|
|
10
|
+
import {
|
|
11
|
+
TabsSample,
|
|
12
|
+
TabsVariantsSample,
|
|
13
|
+
TabsSizesSample,
|
|
14
|
+
TabsWithIconsSample,
|
|
15
|
+
TabsControlledSample,
|
|
16
|
+
TabsAsLinkSample,
|
|
17
|
+
TabsAnimatedIndicatorSample,
|
|
18
|
+
} from "@/components/docs/samples/tabs";
|
|
19
|
+
|
|
20
|
+
<Callout>
|
|
21
|
+
This is a **standalone component** that does not depend on the assistant-ui runtime. Use it anywhere in your application.
|
|
22
|
+
</Callout>
|
|
23
|
+
|
|
24
|
+
<TabsSample />
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
<InstallCommand shadcn={["tabs"]} />
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import {
|
|
34
|
+
Tabs,
|
|
35
|
+
TabsList,
|
|
36
|
+
TabsTrigger,
|
|
37
|
+
TabsContent,
|
|
38
|
+
} from "@/components/assistant-ui/tabs";
|
|
39
|
+
|
|
40
|
+
export function Example() {
|
|
41
|
+
return (
|
|
42
|
+
<Tabs defaultValue="account">
|
|
43
|
+
<TabsList>
|
|
44
|
+
<TabsTrigger value="account">Account</TabsTrigger>
|
|
45
|
+
<TabsTrigger value="password">Password</TabsTrigger>
|
|
46
|
+
</TabsList>
|
|
47
|
+
<TabsContent value="account">Account settings here.</TabsContent>
|
|
48
|
+
<TabsContent value="password">Password settings here.</TabsContent>
|
|
49
|
+
</Tabs>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Examples
|
|
55
|
+
|
|
56
|
+
### Variants
|
|
57
|
+
|
|
58
|
+
Use the `variant` prop on `TabsList` to change the visual style. Child components inherit the variant automatically.
|
|
59
|
+
|
|
60
|
+
<TabsVariantsSample />
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<TabsList variant="default" /> // Muted background with shadow (default)
|
|
64
|
+
<TabsList variant="line" /> // Underline indicator
|
|
65
|
+
<TabsList variant="ghost" /> // Transparent with hover states
|
|
66
|
+
<TabsList variant="pills" /> // Rounded pill buttons
|
|
67
|
+
<TabsList variant="outline" /> // Border with background on active
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Sizes
|
|
71
|
+
|
|
72
|
+
Use the `size` prop on `TabsList` to change the tab height. Child components inherit the size automatically.
|
|
73
|
+
|
|
74
|
+
<TabsSizesSample />
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<TabsList size="sm" /> // 32px height
|
|
78
|
+
<TabsList size="default" /> // 36px height
|
|
79
|
+
<TabsList size="lg" /> // 40px height
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### With Icons
|
|
83
|
+
|
|
84
|
+
Tabs automatically style SVG icons placed inside triggers.
|
|
85
|
+
|
|
86
|
+
<PreviewCode file="components/docs/samples/tabs" name="TabsWithIconsSample">
|
|
87
|
+
<TabsWithIconsSample />
|
|
88
|
+
</PreviewCode>
|
|
89
|
+
|
|
90
|
+
### Controlled
|
|
91
|
+
|
|
92
|
+
Use `value` and `onValueChange` for controlled tab state.
|
|
93
|
+
|
|
94
|
+
<PreviewCode file="components/docs/samples/tabs" name="TabsControlledSample">
|
|
95
|
+
<TabsControlledSample />
|
|
96
|
+
</PreviewCode>
|
|
97
|
+
|
|
98
|
+
### As Link
|
|
99
|
+
|
|
100
|
+
Use the `asChild` prop on `TabsTrigger` to render as a different element, like a navigation link.
|
|
101
|
+
|
|
102
|
+
<PreviewCode file="components/docs/samples/tabs" name="TabsAsLinkSample">
|
|
103
|
+
<TabsAsLinkSample />
|
|
104
|
+
</PreviewCode>
|
|
105
|
+
|
|
106
|
+
### Animated Indicator
|
|
107
|
+
|
|
108
|
+
All variants feature smooth animated indicators that slide between tabs:
|
|
109
|
+
|
|
110
|
+
| Variant | Indicator Style |
|
|
111
|
+
|---------|-----------------|
|
|
112
|
+
| `default` | Sliding background with shadow |
|
|
113
|
+
| `line` | Sliding underline |
|
|
114
|
+
| `ghost` | Sliding background with hover effect |
|
|
115
|
+
| `pills` | Sliding pill background |
|
|
116
|
+
| `outline` | Sliding border |
|
|
117
|
+
|
|
118
|
+
<PreviewCode file="components/docs/samples/tabs" name="TabsAnimatedIndicatorSample">
|
|
119
|
+
<TabsAnimatedIndicatorSample />
|
|
120
|
+
</PreviewCode>
|
|
121
|
+
|
|
122
|
+
## API Reference
|
|
123
|
+
|
|
124
|
+
### Composable API
|
|
125
|
+
|
|
126
|
+
| Component | Description |
|
|
127
|
+
|-----------|-------------|
|
|
128
|
+
| `Tabs` | The root component that manages tab state. |
|
|
129
|
+
| `TabsList` | The container for tab triggers. Set `variant` and `size` here. |
|
|
130
|
+
| `TabsTrigger` | An individual tab button. Inherits variant/size from TabsList. |
|
|
131
|
+
| `TabsContent` | The content panel for a tab. |
|
|
132
|
+
|
|
133
|
+
### Tabs
|
|
134
|
+
|
|
135
|
+
The root component that manages tab state.
|
|
136
|
+
|
|
137
|
+
<ParametersTable
|
|
138
|
+
type="TabsProps"
|
|
139
|
+
parameters={[
|
|
140
|
+
{
|
|
141
|
+
name: "defaultValue",
|
|
142
|
+
type: "string",
|
|
143
|
+
description: "The default active tab value (uncontrolled).",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "value",
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "The controlled active tab value.",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "onValueChange",
|
|
152
|
+
type: "(value: string) => void",
|
|
153
|
+
description: "Callback when the active tab changes.",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "className",
|
|
157
|
+
type: "string",
|
|
158
|
+
description: "Additional CSS classes.",
|
|
159
|
+
},
|
|
160
|
+
]}
|
|
161
|
+
/>
|
|
162
|
+
|
|
163
|
+
### TabsList
|
|
164
|
+
|
|
165
|
+
The container for tab triggers. Set `variant` and `size` here to style all child components.
|
|
166
|
+
|
|
167
|
+
<ParametersTable
|
|
168
|
+
type="TabsListProps"
|
|
169
|
+
parameters={[
|
|
170
|
+
{
|
|
171
|
+
name: "variant",
|
|
172
|
+
type: '"default" | "line" | "ghost" | "pills" | "outline"',
|
|
173
|
+
default: '"default"',
|
|
174
|
+
description: "The visual style of the tabs. Child components inherit this automatically.",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "size",
|
|
178
|
+
type: '"sm" | "default" | "lg"',
|
|
179
|
+
default: '"default"',
|
|
180
|
+
description: "The size of the tabs. Child components inherit this automatically.",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "className",
|
|
184
|
+
type: "string",
|
|
185
|
+
description: "Additional CSS classes.",
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
/>
|
|
189
|
+
|
|
190
|
+
### TabsTrigger
|
|
191
|
+
|
|
192
|
+
An individual tab button.
|
|
193
|
+
|
|
194
|
+
<ParametersTable
|
|
195
|
+
type="TabsTriggerProps"
|
|
196
|
+
parameters={[
|
|
197
|
+
{
|
|
198
|
+
name: "value",
|
|
199
|
+
type: "string",
|
|
200
|
+
required: true,
|
|
201
|
+
description: "The unique value for this tab.",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "asChild",
|
|
205
|
+
type: "boolean",
|
|
206
|
+
default: "false",
|
|
207
|
+
description: "Merge props with child element instead of rendering a button.",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "disabled",
|
|
211
|
+
type: "boolean",
|
|
212
|
+
description: "Whether the tab is disabled.",
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "className",
|
|
216
|
+
type: "string",
|
|
217
|
+
description: "Additional CSS classes.",
|
|
218
|
+
},
|
|
219
|
+
]}
|
|
220
|
+
/>
|
|
221
|
+
|
|
222
|
+
### TabsContent
|
|
223
|
+
|
|
224
|
+
The content panel for a tab.
|
|
225
|
+
|
|
226
|
+
<ParametersTable
|
|
227
|
+
type="TabsContentProps"
|
|
228
|
+
parameters={[
|
|
229
|
+
{
|
|
230
|
+
name: "value",
|
|
231
|
+
type: "string",
|
|
232
|
+
required: true,
|
|
233
|
+
description: "The value matching the corresponding TabsTrigger.",
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "className",
|
|
237
|
+
type: "string",
|
|
238
|
+
description: "Additional CSS classes.",
|
|
239
|
+
},
|
|
240
|
+
]}
|
|
241
|
+
/>
|
|
242
|
+
|
|
243
|
+
### Style Variants (CVA)
|
|
244
|
+
|
|
245
|
+
| Export | Description |
|
|
246
|
+
|--------|-------------|
|
|
247
|
+
| `tabsListVariants` | Styles for the tabs list container. |
|
|
248
|
+
| `tabsActiveIndicatorVariants` | Styles for the animated active indicator. |
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
import {
|
|
252
|
+
tabsListVariants,
|
|
253
|
+
tabsActiveIndicatorVariants,
|
|
254
|
+
} from "@/components/assistant-ui/tabs";
|
|
255
|
+
|
|
256
|
+
<div className={tabsListVariants({ variant: "ghost", size: "sm" })}>
|
|
257
|
+
Custom Tabs Container
|
|
258
|
+
</div>
|
|
259
|
+
```
|