aiellie

Search

Find a component, template or page

GitHub
Components

Suggestions

Prompts to start from: a row of small outline buttons that arrive together, one after another.

Pick one to send it

Open full screen
fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/suggestions"

shadcn needs the @aiellie registry in components.json first. npx aiellie add suggestions adds it on its first run, then installs the same way.

Suggestions is a row of prompts someone can pick instead of typing, like the starters on an empty chat or the follow-ups after a reply. The set arrives together, each one a beat after the one before, and each is an outline Button, so a pick can send at once or fill the composer.

Getting started

  1. Offer a few prompts

    Suggestion is a Button, so onClick does whatever a pick should.

    components/starters.tsx
    import { Suggestion, Suggestions } from "@/components/aiellie/suggestions"
    
    const PROMPTS = ["Explain a concept simply", "Draft a short email"]
    
    export function Starters({ onPick }: { onPick: (prompt: string) => void }) {
      return (
        <Suggestions>
          {PROMPTS.map((prompt) => (
            <Suggestion key={prompt} onClick={() => onPick(prompt)}>
              {prompt}
            </Suggestion>
          ))}
        </Suggestions>
      )
    }

    Show them while the chat is empty, and swap them for the composer's own text once someone starts typing.

Anatomy

<div data-slot="suggestions">
  <button data-slot="suggestion" /> {/* Button, outline, sm */}
</div>

The row wraps, or with scroll stays on one line and scrolls sideways, fading an edge while more of the set is hidden past it. Each child fades and rises in 70ms after the one before it, up to the sixth, from tw-animate-css; with reduced motion they're simply there.

Examples

Fill the composer

Hold the composer's text yourself and a pick can set it, so someone can change the prompt before it goes.

Replay with a fresh set

The row only animates as it mounts. Key it to the set, like the reply it follows, so new follow-ups arrive the same way.

<Suggestions key={reply.id}>
  {reply.followUps.map((followUp) => (
    <Suggestion key={followUp} onClick={() => send(followUp)}>
      {followUp}
    </Suggestion>
  ))}
</Suggestions>

One row over the composer

Starters sit right above the composer, so a pick is next to where the prompt goes. scroll keeps them to one line on a phone rather than wrapping the composer upwards, and justify-center-safe centres them only while they fit.

<Suggestions scroll className="justify-center-safe pb-2">
  {PROMPTS.map((prompt) => (
    <Suggestion key={prompt} onClick={() => send(prompt)}>
      {prompt}
    </Suggestion>
  ))}
</Suggestions>
<Composer />

A quieter look

variant and size are the Button's, so a row under a reply can be ghost.

<Suggestion variant="ghost" size="xs">Shorter</Suggestion>

API reference

Suggestions

PropTypeDefaultDescription
scrollbooleanfalseKeeps the set on one line, scrolling sideways instead of wrapping.
classNamestringMerged onto the row.

All other div props are forwarded.

Suggestion

PropTypeDefaultDescription
variantButton variant"outline"Any of the Button's variants.
sizeButton size"sm"Any of the Button's sizes.

All other Button props are forwarded.