Prompt Suggestions
AI & ChatClickable prompt suggestion chips.
Preview
Usage
example.jsx
import { PromptSuggestions } from "@/components/ui/prompt-suggestions";
export default function Example() {
return <PromptSuggestions />;
}Source Code
Copy this file into components/ui/prompt-suggestions.jsx in your project.
prompt-suggestions.jsx
import { forwardRef } from "react";
import { cn } from "@/lib/utils";
const PromptSuggestions = forwardRef(({ className, suggestions = [], onSelect, ...props }, ref) => (
<div ref={ref} className={cn("flex flex-wrap gap-2", className)} {...props}>
{suggestions.map((s, i) => (
<button key={i} onClick={() => onSelect?.(typeof s === "string" ? s : s.text)}
className="inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm transition-colors hover:bg-accent"
>
{typeof s === "string" ? s : <><span>{s.icon}</span><span>{s.text}</span></>}
</button>
))}
</div>
));
PromptSuggestions.displayName = "PromptSuggestions";
export { PromptSuggestions };
Quick Install
Make sure you have the cn() utility set up. It requires clsx and tailwind-merge.
npm install clsx tailwind-merge