The email
component offers an easy way to set up an email input field for your forms. By simply setting its name
attribute it also automatically defines your id
and makes sure old values are respected.
The email
component comes ready out-of-the-box with Blade UI Kit. Simply install the package and you're good to go.
The most basic usage of the component is to simply reference it:
<x-email />
This will output the following HTML:
<input name="email" type="email" id="email" />
By default an email
type will be set for the input field as well as an id
that allows it to be easily referenced by a label
element.
Of course, you can also specifically set a name
attribute:
<x-email name="email_address" class="p-4" />
This will output the following HTML:
<input name="email_address" type="email" id="email_address" class="p-4" />
The email
component also supports old values that were set. For example, you might want to apply some validation in the backend, but also make sure the user doesn't lose their input data when you re-render the form with any validation errors. When re-rendering the form, the email
component will remember the old value:
<input name="email" type="email" id="email" value="[email protected]" />
© 2024 Dries Vints. Site built with the TALL Stack. Artwork by Caneco.