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 asemail(), also provide validation:
type() method to pass another HTML input type:
Setting the HTML input mode
You may set theinputmode attribute of the input using the inputMode() method:
Setting the numeric step
You may set thestep attribute of the input using the step() method:
Autocompleting text
You may allow the text to be autocompleted by the browser using theautocomplete() method:
autocomplete="off", you may use autocomplete(false):
Autocompleting text with a datalist
You may specify datalist options for a text input using thedatalist() method:
Autocapitalizing text
You may allow the text to be autocapitalized by the browser using theautocapitalize() method:
Adding affix text aside the field
You may place text before and after the input using theprefix() and suffix() methods:
Using icons as affixes
You may place an icon before and after the input using theprefixIcon() and suffixIcon() methods:
Setting the affix icon’s color
Affix icons are gray by default, but you may set a different color using theprefixIconColor() and suffixIconColor() methods:
Revealable password inputs
When usingpassword(), 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 themask() method to configure an Alpine.js mask:
RawJs object:
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 thereadOnly() method:
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 usedehydrated(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 theminLength() and maxLength() methods. These methods add both frontend and backend validation:
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 theminValue() and maxValue() methods:
Phone number validation
When using atel() 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:
telRegex() across all fields, use a service provider: