@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,224 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ModelSelector
|
|
3
|
+
description: Model picker with unified overlay positioning and runtime integration.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { ModelSelectorSample } from "@/components/docs/samples/model-selector";
|
|
7
|
+
|
|
8
|
+
A select component that lets users switch between AI models. Uses item-aligned positioning so the selected model overlays the trigger for a unified look. Integrates with assistant-ui's `ModelContext` system to automatically propagate the selected model to your backend.
|
|
9
|
+
|
|
10
|
+
<ModelSelectorSample />
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
<Steps>
|
|
15
|
+
<Step>
|
|
16
|
+
|
|
17
|
+
### Add `model-selector`
|
|
18
|
+
|
|
19
|
+
<InstallCommand shadcn={["model-selector"]} />
|
|
20
|
+
|
|
21
|
+
</Step>
|
|
22
|
+
<Step>
|
|
23
|
+
|
|
24
|
+
### Use in your application
|
|
25
|
+
|
|
26
|
+
Place the `ModelSelector` inside your thread component, typically in the composer area:
|
|
27
|
+
|
|
28
|
+
```tsx title="/components/assistant-ui/thread.tsx" {1,6-14}
|
|
29
|
+
import { ModelSelector } from "@/components/assistant-ui/model-selector";
|
|
30
|
+
|
|
31
|
+
const ComposerAction: FC = () => {
|
|
32
|
+
return (
|
|
33
|
+
<div className="flex items-center gap-1">
|
|
34
|
+
<ModelSelector
|
|
35
|
+
models={[
|
|
36
|
+
{ id: "gpt-5-nano", name: "GPT-5 Nano", description: "Fast and efficient" },
|
|
37
|
+
{ id: "gpt-5-mini", name: "GPT-5 Mini", description: "Balanced performance" },
|
|
38
|
+
{ id: "gpt-5", name: "GPT-5", description: "Most capable" },
|
|
39
|
+
]}
|
|
40
|
+
defaultValue="gpt-5-mini"
|
|
41
|
+
size="sm"
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</Step>
|
|
49
|
+
<Step>
|
|
50
|
+
|
|
51
|
+
### Read the model in your API route
|
|
52
|
+
|
|
53
|
+
The selected model name is sent as `config.modelName` in the request body:
|
|
54
|
+
|
|
55
|
+
```tsx title="app/api/chat/route.ts" {2,5}
|
|
56
|
+
export async function POST(req: Request) {
|
|
57
|
+
const { messages, config } = await req.json();
|
|
58
|
+
|
|
59
|
+
const result = streamText({
|
|
60
|
+
model: openai(config?.modelName ?? "gpt-4o"),
|
|
61
|
+
messages: convertToModelMessages(messages),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return result.toUIMessageStreamResponse();
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
</Step>
|
|
69
|
+
</Steps>
|
|
70
|
+
|
|
71
|
+
## Variants
|
|
72
|
+
|
|
73
|
+
Use the `variant` prop to change the trigger's visual style.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<ModelSelector variant="outline" /> // Border (default)
|
|
77
|
+
<ModelSelector variant="ghost" /> // No background
|
|
78
|
+
<ModelSelector variant="muted" /> // Solid background
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| Variant | Description |
|
|
82
|
+
| --------- | ---------------------------------------------- |
|
|
83
|
+
| `outline` | Border with transparent background (default) |
|
|
84
|
+
| `ghost` | No background, subtle hover |
|
|
85
|
+
| `muted` | Solid secondary background |
|
|
86
|
+
|
|
87
|
+
## Sizes
|
|
88
|
+
|
|
89
|
+
Use the `size` prop to control the trigger dimensions.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<ModelSelector size="sm" /> // Compact (h-8, text-xs)
|
|
93
|
+
<ModelSelector size="default" /> // Standard (h-9)
|
|
94
|
+
<ModelSelector size="lg" /> // Large (h-10)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Model Options
|
|
98
|
+
|
|
99
|
+
Each model in the `models` array supports:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
const models = [
|
|
103
|
+
{
|
|
104
|
+
id: "gpt-5", // Sent to backend as config.modelName
|
|
105
|
+
name: "GPT-5", // Display name in trigger and items
|
|
106
|
+
description: "Most capable", // Optional subtitle in items only
|
|
107
|
+
icon: <SparklesIcon />, // Optional icon (any ReactNode)
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Runtime Integration
|
|
113
|
+
|
|
114
|
+
The default `ModelSelector` export automatically registers the selected model with assistant-ui's `ModelContext` system. When a user selects a model:
|
|
115
|
+
|
|
116
|
+
1. The component calls `api.modelContext().register()` with `config.modelName`
|
|
117
|
+
2. The `AssistantChatTransport` includes `config` in the request body
|
|
118
|
+
3. Your API route reads `config.modelName` to determine which model to use
|
|
119
|
+
|
|
120
|
+
This works out of the box with `@assistant-ui/react-ai-sdk`.
|
|
121
|
+
|
|
122
|
+
## API Reference
|
|
123
|
+
|
|
124
|
+
### Composable API
|
|
125
|
+
|
|
126
|
+
For custom layouts, use the sub-components directly with `ModelSelector.Root`:
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import {
|
|
130
|
+
ModelSelectorRoot,
|
|
131
|
+
ModelSelectorTrigger,
|
|
132
|
+
ModelSelectorContent,
|
|
133
|
+
ModelSelectorItem,
|
|
134
|
+
} from "@/components/assistant-ui/model-selector";
|
|
135
|
+
|
|
136
|
+
<ModelSelectorRoot models={models} value={modelId} onValueChange={setModelId}>
|
|
137
|
+
<ModelSelectorTrigger variant="outline" />
|
|
138
|
+
<ModelSelectorContent />
|
|
139
|
+
</ModelSelectorRoot>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
| Component | Description |
|
|
143
|
+
|-----------|-------------|
|
|
144
|
+
| `ModelSelector` | Default export with runtime integration |
|
|
145
|
+
| `ModelSelector.Root` | Presentational root (no runtime, controlled state) |
|
|
146
|
+
| `ModelSelector.Trigger` | CVA-styled trigger showing current model |
|
|
147
|
+
| `ModelSelector.Content` | Select content with model items |
|
|
148
|
+
| `ModelSelector.Item` | Individual model option with icon, name, description |
|
|
149
|
+
|
|
150
|
+
### ModelSelector
|
|
151
|
+
|
|
152
|
+
<ParametersTable
|
|
153
|
+
type="ModelSelectorProps"
|
|
154
|
+
parameters={[
|
|
155
|
+
{
|
|
156
|
+
name: "models",
|
|
157
|
+
type: "ModelOption[]",
|
|
158
|
+
required: true,
|
|
159
|
+
description: "Array of available models to display.",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "defaultValue",
|
|
163
|
+
type: "string",
|
|
164
|
+
description: "Initial model ID for uncontrolled usage.",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "value",
|
|
168
|
+
type: "string",
|
|
169
|
+
description: "Controlled selected model ID.",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "onValueChange",
|
|
173
|
+
type: "(value: string) => void",
|
|
174
|
+
description: "Callback when selected model changes.",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "variant",
|
|
178
|
+
type: '"outline" | "ghost" | "muted"',
|
|
179
|
+
default: '"outline"',
|
|
180
|
+
description: "Visual style of the trigger button.",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "size",
|
|
184
|
+
type: '"sm" | "default" | "lg"',
|
|
185
|
+
default: '"default"',
|
|
186
|
+
description: "Size of the trigger button.",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "contentClassName",
|
|
190
|
+
type: "string",
|
|
191
|
+
description: "Additional class name for the dropdown content.",
|
|
192
|
+
},
|
|
193
|
+
]}
|
|
194
|
+
/>
|
|
195
|
+
|
|
196
|
+
### ModelOption
|
|
197
|
+
|
|
198
|
+
<ParametersTable
|
|
199
|
+
type="ModelOption"
|
|
200
|
+
parameters={[
|
|
201
|
+
{
|
|
202
|
+
name: "id",
|
|
203
|
+
type: "string",
|
|
204
|
+
required: true,
|
|
205
|
+
description: "Unique identifier sent to the backend as modelName.",
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "name",
|
|
209
|
+
type: "string",
|
|
210
|
+
required: true,
|
|
211
|
+
description: "Display name shown in trigger and dropdown.",
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "description",
|
|
215
|
+
type: "string",
|
|
216
|
+
description: "Optional subtitle shown below the model name.",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "icon",
|
|
220
|
+
type: "React.ReactNode",
|
|
221
|
+
description: "Optional icon displayed before the model name.",
|
|
222
|
+
},
|
|
223
|
+
]}
|
|
224
|
+
/>
|
|
@@ -3,7 +3,6 @@ title: Message Part Grouping
|
|
|
3
3
|
description: Organize message parts into custom groups with flexible grouping functions.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
7
6
|
import { PartGroupingSample } from "@/components/docs/samples/part-grouping";
|
|
8
7
|
|
|
9
8
|
<PartGroupingSample />
|
|
@@ -464,7 +463,7 @@ type MessagePartGroup = {
|
|
|
464
463
|
|
|
465
464
|
### Group Component Props
|
|
466
465
|
|
|
467
|
-
The Group component receives:
|
|
466
|
+
The `Group` component receives:
|
|
468
467
|
|
|
469
468
|
- `groupKey`: The group identifier (or `undefined` for ungrouped parts)
|
|
470
469
|
- `indices`: Array of indices for the parts in this group
|
|
@@ -513,12 +512,12 @@ Adjust group appearance based on content:
|
|
|
513
512
|
|
|
514
513
|
```tsx
|
|
515
514
|
import { FC, PropsWithChildren } from "react";
|
|
516
|
-
import {
|
|
515
|
+
import { useAuiState } from "@assistant-ui/react";
|
|
517
516
|
|
|
518
517
|
const DynamicGroup: FC<
|
|
519
518
|
PropsWithChildren<{ groupKey: string | undefined; indices: number[] }>
|
|
520
519
|
> = ({ groupKey, indices, children }) => {
|
|
521
|
-
const parts =
|
|
520
|
+
const parts = useAuiState(({ message }) => message.content);
|
|
522
521
|
const groupParts = indices.map((i) => parts[i]);
|
|
523
522
|
|
|
524
523
|
// Analyze group content
|
|
@@ -535,4 +534,4 @@ const DynamicGroup: FC<
|
|
|
535
534
|
</div>
|
|
536
535
|
);
|
|
537
536
|
};
|
|
538
|
-
```
|
|
537
|
+
```
|
|
@@ -3,7 +3,6 @@ title: Reasoning
|
|
|
3
3
|
description: Collapsible UI for displaying AI reasoning and thinking messages.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
7
6
|
import { ReasoningSample, ReasoningGroupSample } from "@/components/docs/samples/reasoning";
|
|
8
7
|
|
|
9
8
|
<ReasoningSample />
|
|
@@ -55,8 +54,8 @@ const AssistantMessage: FC = () => {
|
|
|
55
54
|
|
|
56
55
|
The component consists of two parts:
|
|
57
56
|
|
|
58
|
-
1.
|
|
59
|
-
2.
|
|
57
|
+
1. `Reasoning`: Renders individual reasoning message part content (with markdown support)
|
|
58
|
+
2. `ReasoningGroup`: Wraps consecutive reasoning parts in a collapsible container
|
|
60
59
|
|
|
61
60
|
Consecutive reasoning parts are automatically grouped together by the `ReasoningGroup` component.
|
|
62
61
|
|
|
@@ -91,7 +90,7 @@ const ReasoningGroupImpl: ReasoningGroupComponent = ({
|
|
|
91
90
|
startIndex,
|
|
92
91
|
endIndex,
|
|
93
92
|
}) => {
|
|
94
|
-
const isReasoningStreaming =
|
|
93
|
+
const isReasoningStreaming = useAuiState(({ message }) => {
|
|
95
94
|
if (message.status?.type !== "running") return false;
|
|
96
95
|
const lastIndex = message.parts.length - 1;
|
|
97
96
|
if (lastIndex < 0) return false;
|
|
@@ -111,7 +110,9 @@ const ReasoningGroupImpl: ReasoningGroupComponent = ({
|
|
|
111
110
|
};
|
|
112
111
|
```
|
|
113
112
|
|
|
114
|
-
##
|
|
113
|
+
## API Reference
|
|
114
|
+
|
|
115
|
+
### Composable API
|
|
115
116
|
|
|
116
117
|
All sub-components are exported for custom layouts:
|
|
117
118
|
|
|
@@ -3,19 +3,28 @@ title: Custom Scrollbar
|
|
|
3
3
|
description: Replace the default scrollbar with a custom Radix UI scroll area.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
7
6
|
import { ScrollbarSample } from "@/components/docs/samples/scrollbar";
|
|
8
7
|
|
|
9
8
|
<ScrollbarSample />
|
|
10
9
|
|
|
11
|
-
If you want to show a custom scrollbar UI of the
|
|
10
|
+
If you want to show a custom scrollbar UI of the `ThreadPrimitive.Viewport` in place of the system default, you can integrate `@radix-ui/react-scroll-area`.
|
|
12
11
|
An example implementation of this is [shadcn/ui's Scroll Area](https://ui.shadcn.com/docs/components/scroll-area).
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
<Steps>
|
|
15
14
|
|
|
16
|
-
<
|
|
15
|
+
<Step>
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
### Add shadcn Scroll Area
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx shadcn@latest add scroll-area
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
</Step>
|
|
24
|
+
|
|
25
|
+
<Step>
|
|
26
|
+
|
|
27
|
+
### Add Additional Styles
|
|
19
28
|
|
|
20
29
|
The Radix UI Viewport component adds an intermediate `<div data-radix-scroll-area-content>` element.
|
|
21
30
|
Add the following CSS to your `globals.css`:
|
|
@@ -26,11 +35,15 @@ Add the following CSS to your `globals.css`:
|
|
|
26
35
|
}
|
|
27
36
|
```
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
</Step>
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
<Step>
|
|
41
|
+
|
|
42
|
+
### Integrate with Thread
|
|
43
|
+
|
|
44
|
+
- Wrap `ThreadPrimitive.Root` with `<ScrollAreaPrimitive.Root asChild>`
|
|
45
|
+
- Wrap `ThreadPrimitive.Viewport` with `<ScrollAreaPrimitive.Viewport className="thread-viewport" asChild>`
|
|
46
|
+
- Add shadcn's `<ScrollBar />` to `ThreadPrimitive.Root`
|
|
34
47
|
|
|
35
48
|
The resulting MyThread component should look like this:
|
|
36
49
|
|
|
@@ -54,6 +67,10 @@ const MyThread: FC = () => {
|
|
|
54
67
|
};
|
|
55
68
|
```
|
|
56
69
|
|
|
70
|
+
</Step>
|
|
71
|
+
|
|
72
|
+
</Steps>
|
|
73
|
+
|
|
57
74
|
## Related Components
|
|
58
75
|
|
|
59
76
|
- [Thread](/docs/ui/thread) - The main chat interface where the scrollbar is used
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Select
|
|
3
|
+
description: A dropdown select component with composable sub-components.
|
|
4
|
+
links:
|
|
5
|
+
- label: Radix UI Select
|
|
6
|
+
url: https://www.radix-ui.com/primitives/docs/components/select
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
import { PreviewCode } from "@/components/docs/preview-code.server";
|
|
10
|
+
import {
|
|
11
|
+
SelectSample,
|
|
12
|
+
SelectDisabledItemsSample,
|
|
13
|
+
SelectPlaceholderSample,
|
|
14
|
+
SelectDisabledSample,
|
|
15
|
+
SelectGroupsSample,
|
|
16
|
+
SelectVariantsSample,
|
|
17
|
+
SelectSizesSample,
|
|
18
|
+
SelectScrollableSample,
|
|
19
|
+
} from "@/components/docs/samples/select";
|
|
20
|
+
|
|
21
|
+
<Callout>
|
|
22
|
+
This is a **standalone component** that does not depend on the assistant-ui runtime. Use it anywhere in your application.
|
|
23
|
+
</Callout>
|
|
24
|
+
|
|
25
|
+
<SelectSample />
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
<InstallCommand shadcn={["select"]} />
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { Select } from "@/components/assistant-ui/select";
|
|
35
|
+
|
|
36
|
+
const options = [
|
|
37
|
+
{ value: "apple", label: "Apple" },
|
|
38
|
+
{ value: "banana", label: "Banana" },
|
|
39
|
+
{ value: "orange", label: "Orange" },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export function FruitPicker() {
|
|
43
|
+
const [value, setValue] = useState("apple");
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Select
|
|
47
|
+
value={value}
|
|
48
|
+
onValueChange={setValue}
|
|
49
|
+
options={options}
|
|
50
|
+
placeholder="Select a fruit..."
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
### Variants
|
|
59
|
+
|
|
60
|
+
Use the `variant` prop on `SelectTrigger` to change the visual style.
|
|
61
|
+
|
|
62
|
+
<SelectVariantsSample />
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<SelectTrigger variant="outline" /> // Border (default)
|
|
66
|
+
<SelectTrigger variant="ghost" /> // No border
|
|
67
|
+
<SelectTrigger variant="muted" /> // Solid background
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Sizes
|
|
71
|
+
|
|
72
|
+
Use the `size` prop on `SelectTrigger` to change the height.
|
|
73
|
+
|
|
74
|
+
<SelectSizesSample />
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<SelectTrigger size="default" /> // 36px (default)
|
|
78
|
+
<SelectTrigger size="sm" /> // 32px
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Scrollable
|
|
82
|
+
|
|
83
|
+
Long lists automatically become scrollable.
|
|
84
|
+
|
|
85
|
+
<PreviewCode file="components/docs/samples/select" name="SelectScrollableSample">
|
|
86
|
+
<SelectScrollableSample />
|
|
87
|
+
</PreviewCode>
|
|
88
|
+
|
|
89
|
+
### Groups
|
|
90
|
+
|
|
91
|
+
Use the composable API for grouped options:
|
|
92
|
+
|
|
93
|
+
<PreviewCode file="components/docs/samples/select" name="SelectGroupsSample">
|
|
94
|
+
<SelectGroupsSample />
|
|
95
|
+
</PreviewCode>
|
|
96
|
+
|
|
97
|
+
### Disabled Items
|
|
98
|
+
|
|
99
|
+
<PreviewCode file="components/docs/samples/select" name="SelectDisabledItemsSample">
|
|
100
|
+
<SelectDisabledItemsSample />
|
|
101
|
+
</PreviewCode>
|
|
102
|
+
|
|
103
|
+
### With Placeholder
|
|
104
|
+
|
|
105
|
+
<PreviewCode file="components/docs/samples/select" name="SelectPlaceholderSample">
|
|
106
|
+
<SelectPlaceholderSample />
|
|
107
|
+
</PreviewCode>
|
|
108
|
+
|
|
109
|
+
### Disabled Select
|
|
110
|
+
|
|
111
|
+
<PreviewCode file="components/docs/samples/select" name="SelectDisabledSample">
|
|
112
|
+
<SelectDisabledSample />
|
|
113
|
+
</PreviewCode>
|
|
114
|
+
|
|
115
|
+
## API Reference
|
|
116
|
+
|
|
117
|
+
### Composable API
|
|
118
|
+
|
|
119
|
+
| Component | Description |
|
|
120
|
+
|-----------|-------------|
|
|
121
|
+
| `Select` | A convenience component that renders a complete select with options. |
|
|
122
|
+
| `SelectRoot` | The root component that manages state. |
|
|
123
|
+
| `SelectTrigger` | The button that opens the dropdown. Accepts `variant` and `size` props. |
|
|
124
|
+
| `SelectValue` | Renders the selected value or placeholder. |
|
|
125
|
+
| `SelectContent` | The dropdown content container with animations. |
|
|
126
|
+
| `SelectItem` | An individual selectable item. |
|
|
127
|
+
| `SelectGroup` | Groups related items together. |
|
|
128
|
+
| `SelectLabel` | A label for a group of items. |
|
|
129
|
+
| `SelectSeparator` | A visual separator between items or groups. |
|
|
130
|
+
| `SelectScrollUpButton` | Scroll indicator for long lists. |
|
|
131
|
+
| `SelectScrollDownButton` | Scroll indicator for long lists. |
|
|
132
|
+
|
|
133
|
+
### Select
|
|
134
|
+
|
|
135
|
+
A convenience component that renders a complete select with options.
|
|
136
|
+
|
|
137
|
+
<ParametersTable
|
|
138
|
+
type="SelectProps"
|
|
139
|
+
parameters={[
|
|
140
|
+
{
|
|
141
|
+
name: "value",
|
|
142
|
+
type: "string",
|
|
143
|
+
required: true,
|
|
144
|
+
description: "The controlled value of the select.",
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "onValueChange",
|
|
148
|
+
type: "(value: string) => void",
|
|
149
|
+
required: true,
|
|
150
|
+
description: "Callback when the selected value changes.",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "options",
|
|
154
|
+
type: "SelectOption[]",
|
|
155
|
+
required: true,
|
|
156
|
+
description: "Array of options to display.",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "placeholder",
|
|
160
|
+
type: "string",
|
|
161
|
+
description: "Placeholder text when no value is selected.",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "className",
|
|
165
|
+
type: "string",
|
|
166
|
+
description: "Additional CSS classes for the trigger.",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "disabled",
|
|
170
|
+
type: "boolean",
|
|
171
|
+
description: "Whether the select is disabled.",
|
|
172
|
+
},
|
|
173
|
+
]}
|
|
174
|
+
/>
|
|
175
|
+
|
|
176
|
+
### SelectOption
|
|
177
|
+
|
|
178
|
+
<ParametersTable
|
|
179
|
+
type="SelectOption"
|
|
180
|
+
parameters={[
|
|
181
|
+
{
|
|
182
|
+
name: "value",
|
|
183
|
+
type: "string",
|
|
184
|
+
required: true,
|
|
185
|
+
description: "The value of the option.",
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "label",
|
|
189
|
+
type: "ReactNode",
|
|
190
|
+
required: true,
|
|
191
|
+
description: "The display label for the option.",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "textValue",
|
|
195
|
+
type: "string",
|
|
196
|
+
description: "Optional text value for typeahead. Defaults to label if it's a string.",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "disabled",
|
|
200
|
+
type: "boolean",
|
|
201
|
+
description: "Whether the option is disabled.",
|
|
202
|
+
},
|
|
203
|
+
]}
|
|
204
|
+
/>
|
|
205
|
+
|
|
206
|
+
### SelectTrigger
|
|
207
|
+
|
|
208
|
+
The button that opens the dropdown.
|
|
209
|
+
|
|
210
|
+
<ParametersTable
|
|
211
|
+
type="SelectTriggerProps"
|
|
212
|
+
parameters={[
|
|
213
|
+
{
|
|
214
|
+
name: "variant",
|
|
215
|
+
type: '"outline" | "ghost" | "muted"',
|
|
216
|
+
default: '"outline"',
|
|
217
|
+
description: "The visual style of the trigger.",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "size",
|
|
221
|
+
type: '"sm" | "default" | "lg"',
|
|
222
|
+
default: '"default"',
|
|
223
|
+
description: "The size of the trigger.",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "className",
|
|
227
|
+
type: "string",
|
|
228
|
+
description: "Additional CSS classes.",
|
|
229
|
+
},
|
|
230
|
+
]}
|
|
231
|
+
/>
|
|
232
|
+
|
|
233
|
+
### Style Variants (CVA)
|
|
234
|
+
|
|
235
|
+
| Export | Description |
|
|
236
|
+
|--------|-------------|
|
|
237
|
+
| `selectTriggerVariants` | Styles for the select trigger button. |
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
import { selectTriggerVariants } from "@/components/assistant-ui/select";
|
|
241
|
+
|
|
242
|
+
<button className={selectTriggerVariants({ variant: "ghost", size: "sm" })}>
|
|
243
|
+
Custom Trigger
|
|
244
|
+
</button>
|
|
245
|
+
```
|
|
@@ -3,7 +3,6 @@ title: Sources
|
|
|
3
3
|
description: Display URL sources with favicon, title, and external link.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
7
6
|
import { SourcesSample } from "@/components/docs/samples/sources";
|
|
8
7
|
|
|
9
8
|
<SourcesSample />
|
|
@@ -48,9 +47,9 @@ const AssistantMessage: FC = () => {
|
|
|
48
47
|
Use the `variant` prop to change the visual style.
|
|
49
48
|
|
|
50
49
|
```tsx
|
|
51
|
-
<Source variant="
|
|
52
|
-
<Source variant="outline" /> // Border only
|
|
50
|
+
<Source variant="outline" /> // Border (default)
|
|
53
51
|
<Source variant="ghost" /> // No background
|
|
52
|
+
<Source variant="muted" /> // Solid background
|
|
54
53
|
```
|
|
55
54
|
|
|
56
55
|
## Sizes
|
|
@@ -63,7 +62,9 @@ Use the `size` prop to change the size.
|
|
|
63
62
|
<Source size="lg" /> // Large
|
|
64
63
|
```
|
|
65
64
|
|
|
66
|
-
##
|
|
65
|
+
## API Reference
|
|
66
|
+
|
|
67
|
+
### Composable API
|
|
67
68
|
|
|
68
69
|
The component exports composable sub-components:
|
|
69
70
|
|
|
@@ -82,6 +83,6 @@ import { Source, SourceIcon, SourceTitle } from "@/components/assistant-ui/sourc
|
|
|
82
83
|
| `SourceIcon` | Favicon with domain initial fallback |
|
|
83
84
|
| `SourceTitle` | Truncated title text |
|
|
84
85
|
|
|
85
|
-
## Related
|
|
86
|
+
## Related Components
|
|
86
87
|
|
|
87
88
|
- [PartGrouping](/docs/ui/part-grouping) - Group sources by parentId
|