Skip to content
Guides
Navigation
Feedback
Overlays
Layout
Data Display
Forms
.md

Contact

contact-02

Centred long contact form: name, email and phone fields, a topic select, a radio group, a message and a terms checkbox.

Open full screen

Installation

php artisan ui:add-block contact-02

A single command installs the block's Blade file and every component it depends on. Render it in your own layout as <x-ui.blocks.contact-02 />.

Usage

Every piece of content is a prop, so you can drive this block from a CMS. A field is ['name' =>, 'label' =>, 'type' =>, 'placeholder' =>, 'required' =>, 'width' =>, 'options' =>]. type is text, email, tel, textarea, select or radio (any other value is passed to the input as its type). width is full (default), half (half width at every size) or md:half (full on phones, half from md up). select and radio read 'options': plain strings or ['label' => ..., 'value' => ...]. Pass :terms="false" to drop the checkbox. method can be GET, POST, PUT, PATCH or DELETE; a @csrf field is added for anything but GET unless you pass :csrf="false".

<x-ui.blocks.contact-02
    tagline="Support"
    heading="Get in touch"
    description="We reply within one working day."
    :action="route('contact.store')"
    :fields="[
        ['name' => 'name', 'label' => 'Full name', 'required' => true],
        ['name' => 'email', 'label' => 'Work email', 'type' => 'email', 'width' => 'md:half', 'required' => true],
        ['name' => 'company', 'label' => 'Company', 'width' => 'md:half'],
        ['name' => 'budget', 'label' => 'Budget', 'type' => 'select', 'placeholder' => 'Pick a range', 'options' => ['< 5k', '5k to 20k', '20k+']],
        ['name' => 'source', 'label' => 'How did you hear about us?', 'type' => 'radio', 'options' => ['Search', 'Friend', 'Other']],
        ['name' => 'message', 'label' => 'Project details', 'type' => 'textarea'],
    ]"
    terms="I agree to the"
    :terms-link="['label' => 'privacy policy', 'href' => '/privacy']"
    submit-label="Send message"
/>

Props

Every prop with its default. Pass any of them as attributes, using : to bind a PHP value.

@props([
    'tagline' => 'Tagline',
    'heading' => 'Contact us',
    'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
    'action' => '#',
    'method' => 'POST',
    'csrf' => true,
    'fields' => [
        ['name' => 'first_name', 'label' => 'First name', 'width' => 'half'],
        ['name' => 'last_name', 'label' => 'Last name', 'width' => 'half'],
        ['name' => 'email', 'label' => 'Email', 'type' => 'email', 'width' => 'md:half', 'required' => true],
        ['name' => 'phone', 'label' => 'Phone number', 'type' => 'tel', 'width' => 'md:half'],
        [
            'name' => 'topic',
            'label' => 'Choose a topic',
            'type' => 'select',
            'placeholder' => 'Select one...',
            'options' => ['First topic', 'Second topic', 'Third topic'],
        ],
        [
            'name' => 'role',
            'label' => 'Which best describes you?',
            'type' => 'radio',
            'options' => ['First choice', 'Second choice', 'Third choice', 'Fourth choice', 'Fifth choice', 'Other'],
        ],
        [
            'name' => 'message',
            'label' => 'Message',
            'type' => 'textarea',
            'placeholder' => 'Type your message...',
            'required' => true,
        ],
    ],
    'terms' => 'I accept the',
    'termsLink' => ['label' => 'Terms', 'href' => '#'],
    'submitLabel' => 'Submit',
])