Get Started
Components
- Accordion
- Attachment
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Card
- Checkbox
- Code Block
- Collapsible
- Dialog
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Label
- Marker
- Message
- Number Flow
- Pagination
- Popover
- Progress
- Radio Group
- Select
- Slider
- Sonner
- Spinner
- Switch
- Tooltip
- Separator
- Sheet
- Tabs
- Textarea
- Toggle
- Toggle Group
- Trace
AI Elements
Libraries
Utilities
"use client";
import { ArrowUpIcon, PlusIcon } from "lucide-react";
import * as React from "react";
import { Button } from "@/components/ui/button";
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupTextarea,
} from "@/components/ui/input-group";
import {
Bubble,
BubbleContent,
Message,
MessageContent,
} from "@/components/ui/message";
const suggestions = [
"Add a dark mode toggle",
"Fix the failing build",
"Write tests for the form",
"Upgrade to Next.js 16",
"Add a loading state",
"Find unused dependencies",
];
const replies: Record<string, string> = {
"Add a dark mode toggle":
"Added a ModeToggle to the site header. It calls setTheme from next-themes.",
"Add a loading state":
"Added a loading.tsx to the dashboard route. It shows skeletons while the data loads.",
"Find unused dependencies":
"Three packages are not imported anywhere: lodash, moment and classnames. Should I remove them?",
"Fix the failing build":
"The build failed on a missing import in app/page.tsx. I added it and the build passes.",
"Upgrade to Next.js 16":
"Ran the codemod and bumped next to 16. Two routes needed async params, so I updated them.",
"Write tests for the form":
"Added four tests in signup-form.test.tsx. They cover the empty, invalid and valid states.",
};
export function SuggestionDemo() {
const [text, setText] = React.useState("");
const [turn, setTurn] = React.useState<{
prompt: string;
reply: string;
} | null>(null);
const formRef = React.useRef<HTMLFormElement>(null);
const canSend = text.trim().length > 0;
function send(prompt: string) {
setTurn({
prompt,
reply:
replies[prompt] ?? "This demo only knows the suggestions. Pick one.",
});
setText("");
}
function onSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
if (!canSend) {
return;
}
send(text.trim());
}
return (
<div className="mx-auto flex w-full max-w-lg flex-col gap-6 py-6 text-sm">
{turn && (
<div className="flex flex-col gap-4">
<Message align="end">
<MessageContent>
<Bubble align="end" variant="muted">
<BubbleContent>{turn.prompt}</BubbleContent>
</Bubble>
</MessageContent>
</Message>
<Message>
<MessageContent>
<p>{turn.reply}</p>
</MessageContent>
</Message>
</div>
)}
<div className="flex flex-col gap-2">
<div className="scroll-fade-x no-scrollbar flex gap-2 overflow-x-auto overscroll-x-contain">
{suggestions.map((suggestion) => (
<Button
className="shrink-0 rounded-full"
key={suggestion}
onClick={() => send(suggestion)}
size="sm"
variant="outline"
>
{suggestion}
</Button>
))}
</div>
<form onSubmit={onSubmit} ref={formRef}>
<InputGroup>
<InputGroupTextarea
className="p-3"
onChange={(event) => setText(event.target.value)}
onKeyDown={(event) => {
if (event.key === "Enter" && !event.shiftKey) {
event.preventDefault();
formRef.current?.requestSubmit();
}
}}
placeholder="Ask the agent to change your code..."
value={text}
/>
<InputGroupAddon align="block-end">
<InputGroupButton
aria-label="Attach files"
size="icon-sm"
variant="outline"
>
<PlusIcon />
</InputGroupButton>
<InputGroupButton
aria-label="Send"
className="ml-auto"
disabled={!canSend}
size="icon-sm"
type="submit"
variant="default"
>
<ArrowUpIcon />
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</form>
</div>
</div>
);
}Suggestion renders a horizontal row of starter prompts above the composer. Clicking one sends it immediately. The row scrolls horizontally on narrow widths and fades its edges so the overflow is visible.
Suggestion is a composition, not a primitive. It composes Button and Input Group.
Installation
$ bunx --bun frakment add input-group bubble message button$ npx frakment add input-group bubble message button$ pnpm dlx frakment add input-group bubble message button$ yarn dlx frakment add input-group bubble message button
Install the primitives:
$ bunx --bun frakment add input-group bubble message button$ npx frakment add input-group bubble message button$ pnpm dlx frakment add input-group bubble message button$ yarn dlx frakment add input-group bubble message button
Copy the demo into your project:
"use client";
import { ArrowUpIcon, PlusIcon } from "lucide-react";
import * as React from "react";
import { Button } from "@/components/ui/button";
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupTextarea,
} from "@/components/ui/input-group";
import {
Bubble,
BubbleContent,
Message,
MessageContent,
} from "@/components/ui/message";
const suggestions = [
"Add a dark mode toggle",
"Fix the failing build",
"Write tests for the form",
"Upgrade to Next.js 16",
"Add a loading state",
"Find unused dependencies",
];
const replies: Record<string, string> = {
"Add a dark mode toggle":
"Added a ModeToggle to the site header. It calls setTheme from next-themes.",
"Add a loading state":
"Added a loading.tsx to the dashboard route. It shows skeletons while the data loads.",
"Find unused dependencies":
"Three packages are not imported anywhere: lodash, moment and classnames. Should I remove them?",
"Fix the failing build":
"The build failed on a missing import in app/page.tsx. I added it and the build passes.",
"Upgrade to Next.js 16":
"Ran the codemod and bumped next to 16. Two routes needed async params, so I updated them.",
"Write tests for the form":
"Added four tests in signup-form.test.tsx. They cover the empty, invalid and valid states.",
};
export function SuggestionDemo() {
const [text, setText] = React.useState("");
const [turn, setTurn] = React.useState<{
prompt: string;
reply: string;
} | null>(null);
const formRef = React.useRef<HTMLFormElement>(null);
const canSend = text.trim().length > 0;
function send(prompt: string) {
setTurn({
prompt,
reply:
replies[prompt] ?? "This demo only knows the suggestions. Pick one.",
});
setText("");
}
function onSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
if (!canSend) {
return;
}
send(text.trim());
}
return (
<div className="mx-auto flex w-full max-w-lg flex-col gap-6 py-6 text-sm">
{turn && (
<div className="flex flex-col gap-4">
<Message align="end">
<MessageContent>
<Bubble align="end" variant="muted">
<BubbleContent>{turn.prompt}</BubbleContent>
</Bubble>
</MessageContent>
</Message>
<Message>
<MessageContent>
<p>{turn.reply}</p>
</MessageContent>
</Message>
</div>
)}
<div className="flex flex-col gap-2">
<div className="scroll-fade-x no-scrollbar flex gap-2 overflow-x-auto overscroll-x-contain">
{suggestions.map((suggestion) => (
<Button
className="shrink-0 rounded-full"
key={suggestion}
onClick={() => send(suggestion)}
size="sm"
variant="outline"
>
{suggestion}
</Button>
))}
</div>
<form onSubmit={onSubmit} ref={formRef}>
<InputGroup>
<InputGroupTextarea
className="p-3"
onChange={(event) => setText(event.target.value)}
onKeyDown={(event) => {
if (event.key === "Enter" && !event.shiftKey) {
event.preventDefault();
formRef.current?.requestSubmit();
}
}}
placeholder="Ask the agent to change your code..."
value={text}
/>
<InputGroupAddon align="block-end">
<InputGroupButton
aria-label="Attach files"
size="icon-sm"
variant="outline"
>
<PlusIcon />
</InputGroupButton>
<InputGroupButton
aria-label="Send"
className="ml-auto"
disabled={!canSend}
size="icon-sm"
type="submit"
variant="default"
>
<ArrowUpIcon />
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</form>
</div>
</div>
);
}Update the import paths to match your project setup.
Usage
import { Button } from "@/components/ui/button";<div className="scroll-fade-x no-scrollbar flex gap-2 overflow-x-auto overscroll-x-contain">
{suggestions.map((suggestion) => (
<Button
key={suggestion}
variant="outline"
size="sm"
className="shrink-0"
onClick={() => send(suggestion)}
>
{suggestion}
</Button>
))}
</div>Anatomy
<div className="scroll-fade-x no-scrollbar flex gap-2 overflow-x-auto">
<Button variant="outline" size="sm" />
<Button variant="outline" size="sm" />
<Button variant="outline" size="sm" />
</div>- scroll container — horizontal row, fades edges, hides scrollbar
- Button — one per suggestion,
size="sm"andvariant="outline"
Scrolling
scroll-fade-x adds a mask that fades the left and right edges when the row overflows. no-scrollbar hides the scrollbar. overscroll-x-contain stops the page from scrolling when the row reaches its edge.
Accessibility
- Each suggestion is a button with its prompt as the accessible name.
- The row is keyboard-scrollable with arrow keys when focused.
prefers-reduced-motiondisables the fade animation.
Best Practices
- Use 3 to 6 suggestions. More crowds the row and forces scrolling.
- Phrase them as tasks. "Add a dark mode toggle", not "Dark mode".
- Send on click, not on fill. A suggestion is a decision, not a draft.
- Hide the row once a turn starts. Suggestions are for first-time prompts.