Prompts

A set of suggested questions that starts or continues a chat when the reader clicks one.

Usage

When to reach for Prompts, how to write the items, and what a click leaves to you.

When to use

Prompts is a set of suggested questions in a chat interface. The reader clicks one instead of typing, and you send it as their message.
  • An empty chat, where the reader does not know yet what the assistant can do. A few concrete prompts teach that faster than a paragraph.
  • Follow-ups under an answer, when the next useful question is predictable.
  • Grouped starting points, with children nesting a few questions under each topic.
Use something else when
  • The choices are settings or filters, not messages. That is Segmented, Radio or a Tag list, which keep a selected state. Prompts has no selection.
  • The reader picks commands while typing. Slots and skills on Sender keep that inside the input.
  • There are more than six or so options. A long set of prompts is a menu nobody reads, so pick the best few.

Writing the items

Each prompt is an object in items. Write the label as the thing the reader would type, so clicking it and reading it back in the chat feel the same.
  • Look a prompt up by its key. onItemClick gives you the item, and its label can be any node, so it may not be a string you can send. Keep the message text in your own map, keyed by key, and read it from there.
  • description is for context the label leaves out: which book, which file, which time range. Leave it off when the label says it all.
  • An icon on every prompt or on none. A row where some have one reads as two kinds of prompt.
  • disabled grays a prompt out and gives no reason. If the reader cannot use it, consider leaving it out.

Row, wrap or column

By default the prompts sit in one row and never wrap.
  • Set wrap or vertical on narrow screens. A row wider than its container scrolls sideways with the scrollbar hidden, so on a phone the last prompts are off screen and nothing says so.
  • wrap suits short labels of a word or two. vertical suits full questions, which read better one per line.

Nested prompts

A prompt with children becomes a group: its label is the heading and its children are the clickable prompts, stacked in a column inside it.
  • The parent does not call onItemClick, so do not write a parent that reads like a question. Name the topic instead.
  • Put the groups side by side with the default row, or set wrap when there are more than two or three.
  • Style the nested prompts with the subList and subItem keys of classNames. The item key only reaches the top level.

After a click

Prompts does nothing with a click beyond calling onItemClick. What happens next is yours to build.
  • Send the message right away for an obvious question. Put the text into the Sender instead when the reader is likely to edit it first.
  • Hide the starting prompts once the conversation has begun. They take room above the messages and stop being relevant.
  • fadeIn and fadeInLeft run once on mount. To replay them for new follow-ups, give Prompts a new key.

Restyling it

Reach for the semantic keys before a descendant selector: root, title, list, item, itemContent, subList and subItem. A part with a key keeps its name across versions, and a part reached by class name may not.
  • A width on item makes every prompt the same size, which keeps a wrapped grid even.
  • The card colors come from the theme. Change colorBgContainer or colorBorderSecondary under components.Prompts to recolor only Prompts.