# Suggestion URL: /components/suggestion --- title: Suggestion description: A suggestion component that displays a horizontal row of clickable suggestions for user interaction. path: elements/components/suggestion --- The `Suggestion` component displays a horizontal row of clickable suggestions for user interaction. ## Installation ## Usage ```tsx import { Suggestion, Suggestions } from "@/components/ai-elements/suggestion"; ``` ```tsx ``` ## 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: ```tsx title="app/page.tsx" "use client"; import { Input, PromptInputTextarea, PromptInputSubmit } from "@/components/ai-elements/prompt-input"; import { Suggestion, Suggestions } from "@/components/ai-elements/suggestion"; import { useState } from "react"; import { useChat } from "@ai-sdk/react"; const suggestions = ["Can you explain how to play tennis?", "What is the weather in Tokyo?", "How do I make a really good fish taco?"]; const SuggestionDemo = () => { const [input, setInput] = useState(""); const { sendMessage, status } = useChat(); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (input.trim()) { sendMessage({ text: input }); setInput(""); } }; const handleSuggestionClick = (suggestion: string) => { sendMessage({ text: suggestion }); }; return (
{suggestions.map((suggestion) => ( ))} setInput(e.currentTarget.value)} className="pr-12" />
); }; export default SuggestionDemo; ``` ## Features - Horizontal row of clickable suggestion buttons - Customizable styling with variant and size options - Flexible layout that wraps suggestions on smaller screens - onClick callback that emits the selected suggestion string - Support for both individual suggestions and suggestion lists - Clean, modern styling with hover effects - Responsive design with mobile-friendly touch targets - TypeScript support with proper type definitions ## Examples ### Usage with AI Input ## Props ### `` ', }, }} /> ### `` void', }, '...props': { description: 'Any other props are spread to the underlying shadcn/ui Button component.', type: 'Omit, "onClick">', }, }} />