TextBox

in namespace DotVVM.Controls.Tailwind.Controls

Usage & Scenarios

The Tailwind TextBox uses the same API as the built-in TextBox and only adds Tailwind styling. Use TextBoxFormField when you need a label and validation message inside a Tailwind form.

Sample 1: Styled TextBox

The Tailwind TextBox keeps the built-in TextBox API, so the built-in TextBox documentation covers the full feature set. This sample shows the styled wrapper with Text, Placeholder, Type, Enabled, and the Changed command.

<div class="space-y-3 max-w-md">
    <t:TextBox Text="{value: SearchText}"
               placeholder="Search the documentation"
               Changed="{command: IncrementChanges()}" />

    <t:TextBox Text="{value: Password}"
               Type="Password"
               placeholder="Password"
               Enabled="{value: PasswordEnabled}" />

    <t:CheckBox Text="Enable password field" Checked="{value: PasswordEnabled}" />
</div>

<p>Search text: <strong>{{value: SearchText}}</strong></p>
<p>Password length: <strong>{{value: Password.Length}}</strong></p>
<p><code>Changed</code> command count: <strong>{{value: ChangeCount}}</strong></p>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.tailwind.TextBox.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string SearchText { get; set; } = "Tailwind";

        public string Password { get; set; } = "secret";

        public bool PasswordEnabled { get; set; } = true;

        public int ChangeCount { get; set; }

        public void IncrementChanges()
        {
            ChangeCount++;
        }
    }
}

Properties

Name Type Description Notes Default Value
property icon Enabled Boolean Gets or sets a value indicating whether the control is enabled and can be modified.
attribute
inner element
static value
bindable
default
True
property icon FormatString String Gets or sets a format of presentation of value to client.
attribute
inner element
static value
bindable
default
null
property icon SelectAllOnFocus Boolean Gets or sets whether all text inside the TextBox becomes selected when the element gets focused.
attribute
inner element
static value
bindable
default
False
property icon Text Object Gets or sets the text in the control.
attribute
inner element
static value
bindable
default
property icon Type TextBoxType Gets or sets the mode of the text field.
attribute
inner element
static value
bindable
default
Normal
property icon UpdateTextOnInput Boolean Gets or sets whether the viewmodel property will be updated immediately after change. By default, the viewmodel is updated after the control loses its focus.
attribute
inner element
static value
bindable
default
False

Events

Name Type Description
event icon Changed Command Gets or sets the command that will be triggered when the onchange event is fired.
event icon TextInput Command Gets or sets the command that will be triggered when the user is typing in the field. Be careful when using this event - triggering frequent postbacks can make bad user experience. Consider using static commands or a throttling postback handler.

HTML produced by the control