Skip to main content
The Email component renders an email input field with HTML5 email validation, Bootstrap styling, and validation error handling.

Basic Usage

<x-forms::email name="email" label="Email Address" />

Attributes

name
string
required
The input name attribute. Used for form submission and error handling.
label
string
default:""
The label text displayed for the input. If empty, a label will be auto-generated from the name.
model
mixed
default:"null"
The model instance to bind to. The component will automatically fetch the value from the model using the name attribute.
default
mixed
default:"null"
The default value if no model value or old input exists.
showErrors
boolean
default:"true"
Whether to display validation errors below the input.
showLabel
boolean
default:"true"
Whether to display the label. Set to false to hide the label.
placeholder
string
default:""
Custom placeholder text for the input.
showPlaceholder
boolean
default:"false"
Automatically use the label as placeholder text when true.
required
boolean
default:"false"
Mark the input as required. Adds HTML5 required attribute and displays a required indicator on the label.
inline
boolean
default:"false"
Display the label and input inline (horizontal layout).
floating
boolean
default:"false"
Enable Bootstrap floating label style.
inlineLabelClass
string
default:""
Additional CSS classes for the inline label wrapper.
inlineInputClass
string
default:""
Additional CSS classes for the inline input wrapper.
showJsErrors
boolean
default:"false"
Enable JavaScript-based error display for client-side validation.
framework
string
default:""
Specify a custom framework theme. Defaults to the configured framework.

Examples

Basic Email Input

<x-forms::email 
    name="email" 
    label="Email Address" 
/>

Required Email Field

<x-forms::email 
    name="email" 
    label="Email Address"
    :required="true"
/>

With Model Binding

<x-forms::email 
    name="email" 
    label="User Email"
    :model="$user"
/>

With Default Value

<x-forms::email 
    name="contact_email" 
    label="Contact Email"
    default="[email protected]"
/>

With Placeholder

<x-forms::email 
    name="email" 
    label="Email"
    placeholder="[email protected]"
/>

{{-- Or use label as placeholder --}}
<x-forms::email 
    name="email" 
    label="Email Address"
    :show-placeholder="true"
/>

Floating Label

<x-forms::email 
    name="email" 
    label="Email Address"
    :floating="true"
/>

Inline Layout

<x-forms::email 
    name="email" 
    label="Email"
    :inline="true"
    inline-label-class="col-md-3"
    inline-input-class="col-md-9"
/>

Without Label

<x-forms::email 
    name="newsletter_email" 
    :show-label="false"
    placeholder="Enter your email..."
/>

With Additional Attributes

<x-forms::email 
    name="email" 
    label="Email Address"
    class="custom-email-input"
    autocomplete="email"
    multiple
/>

With Help Text

<x-forms::email name="email" label="Email Address">
    <x-slot:help>
        We'll never share your email with anyone else.
    </x-slot:help>
</x-forms::email>

Newsletter Signup Form

<x-forms::form-open>
    <x-forms::email 
        name="email" 
        label="Subscribe to our newsletter"
        :required="true"
        placeholder="Enter your email address"
    />
    
    <x-forms::submit>Subscribe</x-forms::submit>
</x-forms::form-open>

Value Resolution

The component resolves the input value in the following order:
  1. Old input (from validation errors)
  2. Model value (if model is provided)
  3. Default value (if specified)
  4. Empty string

HTML5 Email Validation

The email input type provides built-in browser validation:
  • Validates email format automatically
  • Shows browser-specific validation messages
  • Works with HTML5 form validation API
  • Can be combined with server-side Laravel validation

Validation Error Display

When validation fails, the input automatically:
  • Adds the is-invalid Bootstrap class
  • Displays error messages below the input (if showErrors is true)
  • Preserves user input through Laravel’s old input

Implementation Details

The Email component:
  • Extends the base Input component with type set to email
  • Supports all standard HTML input attributes via attribute merging
  • Leverages browser’s native email validation
  • Integrates with Laravel’s validation error bag
  • Works seamlessly with Laravel’s old input helper
Source: /src/Views/Components/Email.php:12

Build docs developers (and LLMs) love