TextInput class

An input to allow the user to enter text.

Constructors

TextInput(TextInputOptions)

Properties

errorMessage

The error message to display when the input fails validation. See Input validation for more details.

fallback

An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property.

grid.area

The area of a Layout.AreaGrid layout in which an element should be displayed.

height

The height of the element. When set to stretch, the element will use the remaining vertical space in its container.

id

A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot.

inlineAction

The action that should be displayed as a button alongside the input. Action.ShowCard is not supported.

isMultiline

Controls if the input should allow multiple lines of text.

isRequired

Controls whether the input is required. See Input validation for more details.

isSortKey

Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements.

isVisible

Controls the visibility of the element.

label

The label of the input.

A label should always be provided to ensure the best user experience especially for users of assistive technology.

lang

The locale associated with the element.

maxLength

The maximum length of the text in the input.

placeholder

The text to display as a placeholder when the user hasn't entered a value.

regex

The regular expression to validate the input.

requires

A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided).

separator

Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true.

spacing

Controls the amount of space between this element and the previous one. No space will be added for the first element in a container.

style

The style of the input.

targetWidth

Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see Responsive layout.

type

Must be Input.Text.

value

The default value of the input.

valueChangedAction

An Action.ResetInputs action that will be executed when the value of the input changes.

Methods

from(Omit<ITextInput, "type">)
withErrorMessage(string)
withFallback(FallbackElement)
withHeight(ElementHeight)
withId(string)
withInlineAction(IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction)
withIsMultiline(boolean)
withIsRequired(boolean)
withIsSortKey(boolean)
withIsVisible(boolean)
withLabel(string)
withLang(string)
withMaxLength(number)
withPlaceholder(string)
withRegex(string)
withRequires(IHostCapabilities)
withSeparator(boolean)
withSpacing(Spacing)
withStyle(InputTextStyle)
withTargetWidth(TargetWidth)
withValue(string)
withValueChangedAction(IResetInputsAction)

Constructor Details

TextInput(TextInputOptions)

new TextInput(options?: TextInputOptions)

Parameters

Property Details

errorMessage

The error message to display when the input fails validation. See Input validation for more details.

errorMessage?: string

Property Value

string

fallback

An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property.

fallback?: FallbackElement

Property Value

grid.area

The area of a Layout.AreaGrid layout in which an element should be displayed.

grid.area?: string

Property Value

string

height

The height of the element. When set to stretch, the element will use the remaining vertical space in its container.

height?: ElementHeight

Property Value

id

A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot.

id?: string

Property Value

string

inlineAction

The action that should be displayed as a button alongside the input. Action.ShowCard is not supported.

inlineAction?: IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction

Property Value

isMultiline

Controls if the input should allow multiple lines of text.

isMultiline?: boolean

Property Value

boolean

isRequired

Controls whether the input is required. See Input validation for more details.

isRequired?: boolean

Property Value

boolean

isSortKey

Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements.

isSortKey?: boolean

Property Value

boolean

isVisible

Controls the visibility of the element.

isVisible?: boolean

Property Value

boolean

label

The label of the input.

A label should always be provided to ensure the best user experience especially for users of assistive technology.

label?: string

Property Value

string

lang

The locale associated with the element.

lang?: string

Property Value

string

maxLength

The maximum length of the text in the input.

maxLength?: number

Property Value

number

placeholder

The text to display as a placeholder when the user hasn't entered a value.

placeholder?: string

Property Value

string

regex

The regular expression to validate the input.

regex?: string

Property Value

string

requires

A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided).

requires?: IHostCapabilities

Property Value

separator

Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true.

separator?: boolean

Property Value

boolean

spacing

Controls the amount of space between this element and the previous one. No space will be added for the first element in a container.

spacing?: Spacing

Property Value

style

The style of the input.

style?: InputTextStyle

Property Value

targetWidth

Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see Responsive layout.

targetWidth?: TargetWidth

Property Value

type

Must be Input.Text.

type: "Input.Text" = "Input.Text"

Property Value

"Input.Text"

value

The default value of the input.

value?: string

Property Value

string

valueChangedAction

An Action.ResetInputs action that will be executed when the value of the input changes.

valueChangedAction?: IResetInputsAction

Property Value

Method Details

from(Omit<ITextInput, "type">)

static function from(options: Omit<ITextInput, "type">): TextInput

Parameters

options

Omit<ITextInput, "type">

Returns

withErrorMessage(string)

function withErrorMessage(errorMessage: string): TextInput

Parameters

errorMessage

string

Returns

withFallback(FallbackElement)

function withFallback(fallback: FallbackElement): TextInput

Parameters

fallback
FallbackElement

Returns

withHeight(ElementHeight)

function withHeight(height: ElementHeight): TextInput

Parameters

height
ElementHeight

Returns

withId(string)

function withId(id: string): TextInput

Parameters

id

string

Returns

withInlineAction(IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction)

function withInlineAction(inlineAction: IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction): TextInput

Parameters

Returns

withIsMultiline(boolean)

function withIsMultiline(isMultiline?: boolean): TextInput

Parameters

isMultiline

boolean

Returns

withIsRequired(boolean)

function withIsRequired(isRequired?: boolean): TextInput

Parameters

isRequired

boolean

Returns

withIsSortKey(boolean)

function withIsSortKey(isSortKey?: boolean): TextInput

Parameters

isSortKey

boolean

Returns

withIsVisible(boolean)

function withIsVisible(isVisible?: boolean): TextInput

Parameters

isVisible

boolean

Returns

withLabel(string)

function withLabel(label: string): TextInput

Parameters

label

string

Returns

withLang(string)

function withLang(lang: string): TextInput

Parameters

lang

string

Returns

withMaxLength(number)

function withMaxLength(maxLength: number): TextInput

Parameters

maxLength

number

Returns

withPlaceholder(string)

function withPlaceholder(placeholder: string): TextInput

Parameters

placeholder

string

Returns

withRegex(string)

function withRegex(regex: string): TextInput

Parameters

regex

string

Returns

withRequires(IHostCapabilities)

function withRequires(requires: IHostCapabilities): TextInput

Parameters

Returns

withSeparator(boolean)

function withSeparator(separator?: boolean): TextInput

Parameters

separator

boolean

Returns

withSpacing(Spacing)

function withSpacing(spacing: Spacing): TextInput

Parameters

spacing
Spacing

Returns

withStyle(InputTextStyle)

function withStyle(style: InputTextStyle): TextInput

Parameters

Returns

withTargetWidth(TargetWidth)

function withTargetWidth(targetWidth: TargetWidth): TextInput

Parameters

targetWidth
TargetWidth

Returns

withValue(string)

function withValue(value: string): TextInput

Parameters

value

string

Returns

withValueChangedAction(IResetInputsAction)

function withValueChangedAction(valueChangedAction: IResetInputsAction): TextInput

Parameters

valueChangedAction
IResetInputsAction

Returns