laguagu/claude-code-nextjs-skills / skills/ai-elements
ai-elements
VerifiedMaintains AI chat UI built from elements.ai-sdk.dev AI Elements components already copied into the project. Use when changing or debugging those components (conversations, messages, prompt inputs, attachments, reasoning, tool output, sources). New chat UI uses the shadcn/ui AI Elements patterns (`shadcn` skill).
references/suggestion.md
View on GitHub# Suggestion
A suggestion component that displays a horizontal row of clickable suggestions for user interaction.
The `Suggestion` component displays a horizontal row of clickable suggestions for user interaction.
See `scripts/suggestion.tsx` for this example.
## Installation
```bash
npx ai-elements@latest add suggestion
```
## 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 {
PromptInput,
type PromptInputMessage,
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 = (message: PromptInputMessage) => {
if (message.text.trim()) {
sendMessage({ text: message.text });
setInput("");
}
};
const handleSuggestionClick = (suggestion: string) => {
sendMessage({ text: suggestion });
};
return (
<div className="max-w-4xl mx-auto p-6 relative size-full rounded-lg border h-[600px]">
<div className="flex flex-col h-full">
<div className="flex flex-col gap-4">
<Suggestions>
{suggestions.map((suggestion) => (
<Suggestion
key={suggestion}
onClick={handleSuggestionClick}
suggestion={suggestion}
/>
))}
</Suggestions>
<PromptInput
onSubmit={handleSubmit}
className="mt-4 w-full max-w-2xl mx-auto relative"
>
<PromptInputTextarea
value={input}
placeholder="Say something..."
onChange={(e) => setInput(e.currentTarget.value)}
className="pr-12"
/>
<PromptInputSubmit
status={status === "streaming" ? "streaming" : "ready"}
disabled={!input.trim()}
className="absolute bottom-1 right-1"
/>
</PromptInput>
</div>
</div>
</div>
);
};
export default SuggestionDemo;
```
## Features
- Horizontal row of clickable suggestion buttons
- Customizable styling with variant and size options
- Single non-wrapping row: `Suggestions` uses a horizontal `ScrollArea` with a hidden scrollbar; edit generated source if wrapping is needed
- 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
See `scripts/suggestion-input.tsx` for this example.
## Follow-up Suggestions in Chat
Display AI-generated follow-up suggestions after the last assistant message:
```tsx
import { Suggestion, Suggestions } from '@/components/ai-elements/suggestion';
import { Spinner } from '@/components/ui/spinner';
// After your message list in ConversationContent:
{!isGenerating && (isLoadingSuggestions || suggestions.length > 0) && (
<div className="pt-2">
{isLoadingSuggestions ? (
<div className="flex items-center gap-2 text-xs text-muted-foreground">
<Spinner className="size-3" />
<span>Loading suggestions…</span>
</div>
) : (
<Suggestions>
{suggestions.map((s, i) => (
<Suggestion
key={i}
suggestion={s}
onClick={(suggestion) => {
sendMessage({ text: suggestion });
}}
>
{s}
</Suggestion>
))}
</Suggestions>
)}
</div>
)}
```
## Props
### `<Suggestions />`
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `...props` | `React.ComponentProps<typeof ScrollArea>` | - | Any other props are spread to the underlying ScrollArea component. |
### `<Suggestion />`
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `suggestion` | `string` | Required | The suggestion string to display and emit on click. |
| `onClick` | `(suggestion: string) => void` | - | Callback fired when the suggestion is clicked. |
| `...props` | `Omit<React.ComponentProps<typeof Button>, ` | - | Any other props are spread to the underlying shadcn/ui Button component. |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |