AI Elements

Suggestion

Suggestion is a short prompt that the user sends to the agent with one click.

The user sends a suggestion without typing. Each suggestion is a Button with the prompt as its label. Put a row of suggestions above the Prompt Input.

Installation#

Suggestion is built with the Button component.

npx shadcn@latest add @formance/button

Usage#

import { Button } from '@/components/ui/button';
<div className="scrollbar-none flex scroll-fade-x gap-2 overflow-x-auto overscroll-x-contain">  {suggestions.map((suggestion) => (    <Button      key={suggestion}      variant="outline"      size="sm"      caseSensitive      className="shrink-0"      onClick={() => send(suggestion)}    >      {suggestion}    </Button>  ))}</div>

The Formance Button shows its label in uppercase. A suggestion is a prompt, so set caseSensitive to keep the case of the text.

Scrolling#

When the suggestions do not fit, the row scrolls horizontally. scroll-fade-x fades the edge that has more content, and shrink-0 keeps each label on one line.

AI SDK#

The label is the message. Send it without changes.

sendMessage({ text: suggestion });