Conversation

Prompt Suggestions

Starter prompts for an empty chat and follow-up chips under an answer.

3 variantsMIT

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/prompt-suggestions.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { PromptSuggestions } from "@/components/ui/prompt-suggestions";
import { ChartBar, Globe } from "@phosphor-icons/react";

// Empty chat. data stays null until the first suggestion request resolves.
export function StarterPrompts({ query }: { query: SuggestionsQuery }) {
  return (
    <PromptSuggestions
      heading="What should we work on?"
      data={query.data ?? null}
      loading={query.isRefetching}
      skeleton={{ count: 4 }}
      onSelect={(_, prompt) => chat.send(prompt)}
    />
  );
}

// Loaded starter cards
<PromptSuggestions
  heading="What should we work on?"
  data={[
    { id: "i18n", icon: Globe, title: "Localize the onboarding flow", hint: "German and Japanese" },
    { id: "chart", icon: ChartBar, title: "Chart last month's signups", hint: "By plan" },
  ]}
  onSelect={(_, prompt) => chat.send(prompt)}
/>

// Follow-ups under an answer. refreshing keeps the current chips visible;
// loading is for replacing the whole set with the skeleton.
<PromptSuggestions
  variant="chips"
  data={answer.followUps}
  refreshing={answer.loadingMore}
  onRefresh={() => chat.suggestMore(answer.id)}
  onSelect={(_, prompt) => chat.send(prompt)}
/>

Props

PropTypeDefaultDescription
data*PromptSuggestion[] | null—Suggestions in display order. New ids animate in, old ones out. Pass null while they load; an empty array is valid loaded empty data.
loadingbooleanfalseForce the layout-preserving skeleton while refetching, even when stale suggestions are available.
skeleton{ count?: number }—Shape hints for the loading state; count is the number of card or chip placeholders before the real cardinality is known.
variant"cards" | "chips""cards"Cards with icon and hint for an empty chat; wrapping chips for follow-ups.
onSelect*(suggestion, prompt: string) => void—Called with the suggestion and the text to send (`prompt` or the title).
onRefresh() => void—Shows a refresh button after the chips.
refreshingbooleanfalseSpins the refresh icon and disables the current chips. Unlike loading, it keeps the loaded suggestions visible.
headingstring—Label above the suggestions; also their accessible name.
labelsPartial<PromptSuggestionsLabels>—Your own UI strings (the labels.loading announcement, More suggestions, list names for screen readers…), for translating. Right-to-left works under `dir="rtl"`.
classNamestring—Extra classes for the root.
type PromptSuggestion = {
  id: string;
  title: string;
  hint?: string;   // second line on cards
  icon?: Icon;     // from @phosphor-icons/react
  prompt?: string; // text to send; defaults to the title
};