---
title: "Suggestion"
description: "Choose a prompt suggestion and inspect the selected local prompt."
---

# Suggestion

Choose a prompt suggestion and inspect the selected local prompt.

## Usage

Choose a prompt suggestion or write your own message and submit it locally.

## Example

```contract
use uiFontFamily, ButtonAI as ButtonContent from "@rightui/ui"
use Composer from "@rightui/ui"
use BubbleFrame from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiFont: string
  state prompt = ""
  state reply = ""
  state turnSequence = 0
  action send(value: string)
    turnSequence = turnSequence + 1
    prompt = value
    reply = value == "Add a dark mode toggle" ? "Added a ModeToggle to the site header. It calls setTheme from next-themes." : value == "Fix the failing build" ? "The build failed on a missing import in app/page.tsx. I added it and the build passes." : value == "Write tests for the form" ? "Added four tests in signup-form.test.tsx. They cover the empty, invalid and valid states." : value == "Upgrade to Next.js 16" ? "Ran the codemod and bumped next to 16. Two routes needed async params, so I updated them." : value == "Add a loading state" ? "Added a loading.tsx to the dashboard route. It shows skeletons while the data loads." : value == "Find unused dependencies" ? "Three packages are not imported anywhere: lodash, moment and classnames. Should I remove them?" : "This demo only knows the suggestions. Pick one."
  view
    column width="100%" max-width="32rem" gap="ui.space-24" padding="ui.space-24 ui.space-0" font-size="ui.text-sm"
      if prompt != ""
        column gap="ui.space-16"
          BubbleFrame(id="ai-suggestion-user", align="end", variant="muted")
            text prompt font-family=uiFontFamily(uiFont) data-rightui-font="body"
          text reply role="status" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      column gap="ui.space-8"
        row gap="ui.space-8" overflow-x="auto"
          for suggestion, i in ["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"] key=suggestion
            ButtonContent(id="ai-suggestion-prompt-" + i.toString(), label=suggestion, variant="outline", size="sm", disabled=false, press=send(suggestion))
              text suggestion white-space="nowrap" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        for epoch in [turnSequence] key=epoch
          Composer(id="ai-suggestion", menus=false, reduced=reduced, sent=send)

```

## Keyboard

Tab to actions and disclosures; Enter or Space activates them.

## Demo runtime

Timed examples use an injected clock. Add these members to your root component. Replace the scripted state with events from your TypeScript or Rust data source when connecting a model.

```contract
use defaultFontWeights from "@rightui/ui"
  state demoTime = 0
  state demoUntil = 0
  provide
    uiFont = "theme"
    uiWeights = defaultFontWeights()
    rightuiDemoTime = demoTime
    rightuiRunDemo = runDemo
  action runDemo(duration: number)
    demoUntil = max(demoUntil, demoTime + duration)
  action tickDemo
    demoTime = min(demoUntil, demoTime + 32)
  task demoClock when demoTime < demoUntil
    every(32, tickDemo)
```

## Source

File: patterns/ai-elements/suggestion.contract

```contract
use uiFontFamily, ButtonAI as ButtonContent from "@rightui/ui"
use Composer from "@rightui/ui"
use BubbleFrame from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiFont: string
  state prompt = ""
  state reply = ""
  state turnSequence = 0
  action send(value: string)
    turnSequence = turnSequence + 1
    prompt = value
    reply = value == "Add a dark mode toggle" ? "Added a ModeToggle to the site header. It calls setTheme from next-themes." : value == "Fix the failing build" ? "The build failed on a missing import in app/page.tsx. I added it and the build passes." : value == "Write tests for the form" ? "Added four tests in signup-form.test.tsx. They cover the empty, invalid and valid states." : value == "Upgrade to Next.js 16" ? "Ran the codemod and bumped next to 16. Two routes needed async params, so I updated them." : value == "Add a loading state" ? "Added a loading.tsx to the dashboard route. It shows skeletons while the data loads." : value == "Find unused dependencies" ? "Three packages are not imported anywhere: lodash, moment and classnames. Should I remove them?" : "This demo only knows the suggestions. Pick one."
  view
    column width="100%" max-width="32rem" gap="ui.space-24" padding="ui.space-24 ui.space-0" font-size="ui.text-sm"
      if prompt != ""
        column gap="ui.space-16"
          BubbleFrame(id="ai-suggestion-user", align="end", variant="muted")
            text prompt font-family=uiFontFamily(uiFont) data-rightui-font="body"
          text reply role="status" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      column gap="ui.space-8"
        row gap="ui.space-8" overflow-x="auto"
          for suggestion, i in ["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"] key=suggestion
            ButtonContent(id="ai-suggestion-prompt-" + i.toString(), label=suggestion, variant="outline", size="sm", disabled=false, press=send(suggestion))
              text suggestion white-space="nowrap" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        for epoch in [turnSequence] key=epoch
          Composer(id="ai-suggestion", menus=false, reduced=reduced, sent=send)

```
