Skip to content

Commit

Permalink
feat: ThreadPrimitive.Suggestion (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Jun 27, 2024
1 parent f29595b commit 6f03b93
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions apps/www/pages/reference/primitives/Thread.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,68 @@ const ScrollToBottom = () => {
};
```

### `ThreadPrimitive.Suggestion`

Shows a suggestion to the user. When the user clicks on the suggestion, the composer's value is set to the suggestion's prompt.

This primitive renders a `<button>` element unless `asChild` is set.

```tsx
import { ThreadPrimitive } from "@assistant-ui/react";

const Suggestion = () => {
return (
<ThreadPrimitive.Suggestion
prompt="I need help with product search"
method="replace"
autoSend
/>
);
};

<ParametersTable
type="ThreadPrimitiveSuggestionProps"
parameters={[
{
name: "prompt",
type: "string",
description: "The suggestion's prompt.",
},
{
name: "method",
type: "'replace'",
description: "How does the suggestion interact with the composer's existing value.",
},
{
name: "autoSend",
type: "boolean",
description: "Whether to automatically send the suggestion when the user clicks on it.",
default: "false",
},
]}
/>
```

#### `useThreadSuggestion`

```tsx
import { useThreadSuggestion } from "@assistant-ui/react";

const Suggestion = () => {
const suggestion = useThreadSuggestion({
prompt: "Write me a poem about the weather",
method: "replace",
autoSend: true,
});

return (
<button onClick={suggestion}>
Write me a poem about the weather
</button>
);
};
```

### If

Renders children if a condition is met.
Expand Down

0 comments on commit 6f03b93

Please sign in to comment.