Suggestion

The Suggestion component displays a horizontal row of clickable suggestions for user interaction.

Installation

pnpm dlx shadcn-svelte@latest add https://svelte-ai-elements.vercel.app/r/suggestion.json

If you prefer using jsrepo, please install via the command below:

pnpm dlx jsrepo add @ai/elements/ai-elements/suggestion

Usage

Usage with AI SDK

Build a simple input with suggestions users can click to send a message to the LLM.

Add the following component to your frontend:

+page.svelte

Add the following route to your backend:

api/chat/+server.ts

Props

Suggestion

PropTypeDefaultDescription
suggestionstring-The suggestion text to display and pass to the onclick handler
onclick(suggestion: string) => void-Callback fired when the suggestion is clicked, receives the suggestion text
childrenSnippet-Custom content to render instead of the suggestion text
classstring-Additional CSS classes to apply to the suggestion button
variantButtonProps['variant']'outline'Button variant style
sizeButtonProps['size']'sm'Button size
...restPropsButtonProps-All other Button component props are supported

Suggestions

PropTypeDefaultDescription
childrenSnippet-Suggestion components to render in the scrollable container
classstring-Additional CSS classes to apply to the suggestions container
orientation'vertical' | 'horizontal' | 'both''horizontal'Scroll direction for the suggestions container
scrollbarXClassesstring-Custom CSS classes for the horizontal scrollbar
scrollbarYClassesstring-Custom CSS classes for the vertical scrollbar
...restPropsScrollAreaProps-All other ScrollArea component props are supported