Blazor PromptBox Overview
The Blazor PromptBox component facilitates human-AI communication with a feature-rich input interface. It combines text input, speech-to-text functionality, file attachments, and intelligent layout adaptation to provide a comprehensive user experience for AI workflows.
The component also offers advanced functionality like automatic mode switching, integrated action buttons, and customizable adornments.
Basic Usage
- Add the
<TelerikPromptBox>tag to a Razor file. - Set the
Valueparameter to astringobject. It supports one-way and two-way binding. - (optional) Set the
Modeparameter to control input behavior:SingleLine,MultiLine, orAuto(default). - (optional) Configure built-in features like
EnableSpeechToTextandEnableFileSelect. - (optional) Handle the
OnPromptActionevent to respond to user submissions.
Basic PromptBox with auto-expanding mode
<TelerikPromptBox @bind-Value="@Prompt"
Mode="PromptBoxMode.Auto"
Placeholder="Type, speak, or attach files…"
OnPromptAction="@OnActionButtonClick" />
<p>Current prompt: @Prompt</p>
@code {
private string Prompt = string.Empty;
private async Task OnActionButtonClick(PromptBoxActionButtonEventArgs args)
{
if (args.Action == PromptBoxActionType.Send)
{
// Process the user input
Console.WriteLine($"User submitted: {args.Text}");
// Clear the prompt after processing
Prompt = string.Empty;
}
}
}
Input Modes
The component supports three input modes that adapt to different use cases. Read more about PromptBox modes....
File Attachments
Users can attach files directly through the integrated file selection button. Read more about PromptBox file attachments....
Adornments
The PromptBox supports customizable adornments that adapt to the current input mode. You can add custom buttons, icons, or components as prefixes, suffixes, or top-level elements. Read more about PromptBox adornments....
Events
The PromptBox fires events to respond to user interactions and state changes. Read more about PromptBox events....
PromptBox API
To review all available parameters for the PromptBox component, see the PromptBox API Reference.