Suggestions
Show quick prompt chips and write the selected suggestion into InputBar for fast message drafting. Use disabled to pause interaction and item.className for per-chip styling.
Getting Started
$pnpm dlx shadcn@latest add https://agent-elements.21st.dev/r/suggestions.jsonExamples
Icons + text
Fill InputBar
Source
Copy and paste the following code into your project, or run the install command above to pull it in automatically.
components/input/suggestions.tsx
"use client";
import type { ReactNode } from "react";
import { cn } from "../../utils/cn";
export type SuggestionItem = {
id: string;
label: string;
value?: string;
icon?: ReactNode;
className?: string;
};
export type SuggestionsProps = {
items: SuggestionItem[];
onSelect: (item: SuggestionItem) => void;
disabled?: boolean;
className?: string;
itemClassName?: string;
};
export function Suggestions({
items,
onSelect,
disabled,
className,
itemClassName,
}: SuggestionsProps) {
if (items.length === 0) {
return null;
}
return (
<div className={cn("flex flex-wrap items-center gap-2", className)}>
{items.map((item) => (
<button
key={item.id}
type="button"
disabled={disabled}
onClick={() => onSelect(item)}
className={cn(
"inline-flex h-7 items-center gap-1 rounded-[6px] border border-border bg-transparent px-2 text-sm text-an-foreground-muted transition-colors hover:bg-an-background-secondary/40 hover:text-an-foreground disabled:opacity-50 disabled:pointer-events-none",
itemClassName,
item.className,
)}
>
{item.icon && (
<span className="inline-flex shrink-0">{item.icon}</span>
)}
{item.label}
</button>
))}
</div>
);
}
API reference
Prop
Type
Required
items
SuggestionItem[]
Yes
onSelect
(item: SuggestionItem) => void
Yes
disabled
boolean
No
className
string
No
itemClassName
string
No