Skip to main content
You are currently viewing the documentation for Filament 3.x, which is a previous version of Filament.Looking for the current stable version? Visit the 5.x documentation.

Overview

The text input allows you to interact with a string:

Setting the HTML input type

You may set the type of string using a set of methods. Some, such as email(), also provide validation:
You may instead use the type() method to pass another HTML input type:

Setting the HTML input mode

You may set the inputmode attribute of the input using the inputMode() method:

Setting the numeric step

You may set the step attribute of the input using the step() method:

Autocompleting text

You may allow the text to be autocompleted by the browser using the autocomplete() method:
As a shortcut for autocomplete="off", you may use autocomplete(false):
For more complex autocomplete options, text inputs also support datalists.

Autocompleting text with a datalist

You may specify datalist options for a text input using the datalist() method:
Datalists provide autocomplete options to users when they use a text input. However, these are purely recommendations, and the user is still able to type any value into the input. If youโ€™re looking to strictly limit users to a set of predefined options, check out the select field.

Autocapitalizing text

You may allow the text to be autocapitalized by the browser using the autocapitalize() method:

Adding affix text aside the field

You may place text before and after the input using the prefix() and suffix() methods:

Using icons as affixes

You may place an icon before and after the input using the prefixIcon() and suffixIcon() methods:

Setting the affix iconโ€™s color

Affix icons are gray by default, but you may set a different color using the prefixIconColor() and suffixIconColor() methods:

Revealable password inputs

When using password(), you can also make the input revealable(), so that the user can see a plain text version of the password theyโ€™re typing by clicking a button:

Input masking

Input masking is the practice of defining a format that the input value must conform to. In Filament, you may use the mask() method to configure an Alpine.js mask:
To use a dynamic mask, wrap the JavaScript in a RawJs object:
Alpine.js will send the entire masked value to the server, so you may need to strip certain characters from the state before validating the field and saving it. You can do this with the stripCharacters() method, passing in a character or an array of characters to remove from the masked value:

Making the field read-only

Not to be confused with disabling the field, you may make the field โ€œread-onlyโ€ using the readOnly() method:
There are a few differences, compared to disabled():
  • When using readOnly(), the field will still be sent to the server when the form is submitted. It can be mutated with the browser console, or via JavaScript. You can use dehydrated(false) to prevent this.
  • There are no styling changes, such as less opacity, when using readOnly().
  • The field is still focusable when using readOnly().

Text input validation

As well as all rules listed on the validation page, there are additional rules that are specific to text inputs.

Length validation

You may limit the length of the input by setting the minLength() and maxLength() methods. These methods add both frontend and backend validation:
You can also specify the exact length of the input by setting the length(). This method adds both frontend and backend validation:

Size validation

You may validate the minimum and maximum value of a numeric input by setting the minValue() and maxValue() methods:

Phone number validation

When using a tel() field, the value will be validated using: /^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\.\/0-9]*$/. If you wish to change that, then you can use the telRegex() method:
Alternatively, to customize the telRegex() across all fields, use a service provider: