Use a text box when the user needs to enter a single line of text, such as a name or email address. Every text box must have a label. If the field is required, show an asterisk (*) next to the label.
You can include optional guidance text to help users understand what to enter. If the guidance is longer than a short sentence, use a guidance accordion instead.
Choose the appropriate input type in the HTML to help with accessibility, validation and the right on-screen keyboard on touch-screen devices.
Common input types
text – for general short text
number - for numbers
email – for email addresses
tel – for phone numbers
password – for concealed input
Do:
use a text box only for single-line input, for longer text, use a text area
choose a text box size that matches the length of content users are expected to enter
always include a visible label that clearly describes what the user should enter
Avoid:
using a text box when users must choose from a set list of options, instead use a select or radio button group
relying on placeholder text because it can be inaccessible to some users, may not meet contrast requirements, and can be mistaken for pre-filled content
Parameters for turas-text-box
asp-for - binds the text box to a model property
guidance-text - provides additional guidance for the user
field-column-widths - sets the column width for the text box
additional-classes - allows for custom CSS classes to be added
hide-validation-message - suppresses validation messages for the field
readonly - makes the text box read-only
asp-is-disabled - disables the text box
hide-label - hides the label associated with the text box