Prompt Suggestions

Clickable suggestion chips that start a chat.

PromptSuggestions is new in v0.4.0. It shows a row of suggested prompts as chips, usually in an empty Chat, and passes the one the user clicks to OnSelect.

Installation

bash
shellui add prompt-suggestions

Usage

Basic

Picked: nothing yet

<div class="w-full max-w-xl space-y-3">
    <PromptSuggestions Suggestions="suggestions" OnSelect="@(s => picked = s)" />
    <p class="text-sm text-muted-foreground">Picked: @(picked ?? "nothing yet")</p>
</div>

@code {
    private readonly string[] suggestions = { "What is ShellUI?", "Show me a dialog example", "How do I add a theme?" };
    private string? picked;
}

In a chat

Put it in the chat's Footer above the input while the conversation is empty, and send the picked suggestion the same way as typed text. Disabled stops a second pick while a reply is on its way.

ShellUI
Hi! I'm a ShellUI chat demo. Pick a question or type your own.
<Chat Height="380px" Class="w-full max-w-xl">
    <ChildContent>
        @foreach (var message in messages)
        {
            <ChatMessage Role="@message.Role" Name="@(message.Role == "user" ? "You" : "ShellUI")" Text="@message.Text" />
        }
        @if (thinking)
        {
            <ChatMessage Role="assistant" Name="ShellUI" IsStreaming="true" />
        }
    </ChildContent>
    <Footer>
        @if (messages.Count == 1)
        {
            <PromptSuggestions Suggestions="suggestions" OnSelect="SendAsync" Disabled="thinking" Class="mb-3" />
        }
        <ChatInput @bind-Value="draft" OnSubmit="SendAsync" IsLoading="thinking" />
    </Footer>
</Chat>

@code {
    private readonly List<(string Role, string Text)> messages = new()
    {
        ("assistant", "Hi! I'm a ShellUI chat demo. Pick a question or type your own."),
    };

    private readonly string[] suggestions = { "What is ShellUI?", "Show me a dialog example", "How do I add a theme?" };
    private string? draft;
    private bool thinking;

    private async Task SendAsync(string text)
    {
        messages.Add(("user", text));
        thinking = true;
        StateHasChanged();
        await Task.Delay(800);
        messages.Add(("assistant", $"You asked:\n{text}"));
        thinking = false;
    }
}

API Reference

Parameter Type Default Description
Suggestions IEnumerable<string> empty The prompts to show, one chip each
OnSelect EventCallback<string> — Called with the clicked suggestion
Disabled bool false Disables every chip
Class string? null Additional CSS classes for the wrapper

Other attributes are passed to the wrapping <div>.

Accessibility

  • Each suggestion is a <button type="button">, so it can be reached with Tab and pressed with Enter or Space
  • Chips show a focus ring when focused from the keyboard

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.