← Prompt Box API

Component · v2.7.0

NgbPromptBoxComponent

A labeled prompt composer with suggestions, submission and cancellation events.

Import

import { NgbPromptBoxComponent } from '@angular-bootstrap/ngbootstrap';

Selector:ngb-prompt-box

Usage notes

  • This is a presentation component. Your application owns provider requests, credentials, cancellation, persistence and error handling. Rendered response text is not executable HTML.

Declaration

Inputs

value

Current text; supports [(value)] two-way binding.

readonly value: i0.ModelSignal<string>

label

Visible heading or label for the component.

readonly label: i0.InputSignal<string>

placeholder

Placeholder shown when the text is empty.

readonly placeholder: i0.InputSignal<string>

submitLabel

Text of the submit button.

readonly submitLabel: i0.InputSignal<string>

stopLabel

Text of the stop button shown while busy.

readonly stopLabel: i0.InputSignal<string>

suggestions

Suggested prompts shown as buttons in the composer.

readonly suggestions: i0.InputSignal<readonly string[]>

disabled

Disables user actions. This does not cancel an existing backend request.

readonly disabled: i0.InputSignal<boolean>

busy

Marks a request in progress and prevents another submission. The application controls this state.

readonly busy: i0.InputSignal<boolean>

maxLength

Maximum text length. Finite values are floored and clamped to at least 1; invalid numbers use 4000.

readonly maxLength: i0.InputSignal<number>

submitOnEnter

When true, Enter submits and Shift+Enter inserts a newline. Composition events do not submit.

readonly submitOnEnter: i0.InputSignal<boolean>

clearOnSubmit

Clears the text before emitting a successful submission when true.

readonly clearOnSubmit: i0.InputSignal<boolean>

Outputs

promptSubmit

Emits trimmed, nonempty text only when enabled, idle and within the length limit.

readonly promptSubmit: i0.OutputEmitterRef<string>

stop

Requests cancellation. The application must abort its backend request and clear busy.

readonly stop: i0.OutputEmitterRef<void>

valueChange

Emits when value changes through the component. Use [(value)] for two-way binding.

valueChange: OutputRef<string>

Properties

descriptionId

readonly descriptionId: string

Default:`ngb-ai-prompt-help-${nextPromptId++}`

limit

readonly limit: i0.Signal<number>

canSubmit

readonly canSubmit: i0.Signal<boolean>

Methods

updateValue

updateValue(event: Event): void

choose

choose(value: string): void

submit

submit(): void

onKeydown

onKeydown(event: KeyboardEvent): void
Source: src/ai/src/prompt-box.component.ts in the installed @angular-bootstrap/ngbootstrap package. Angular compiler metadata and private members are omitted.

This project is not affiliated with ng-bootstrap or ngx-bootstrap. Those projects focus mainly on Bootstrap components for Angular. ngbootstrap focuses on Angular UI for data-heavy apps, especially Data Grid, Angular-native Form Builder, drag and drop workflows, documentation examples, and performance-focused Angular patterns.