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

Contact

contact-10

Contact form with name, email, phone, topic select, radio group, message and terms checkbox, beside email, phone and office details.

Open full screen

Installation

php artisan ui:add-block contact-10

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-10 />.

Usage

Contact form beside the contact details. Every piece of content is a prop. A field is ['type' => ..., 'name' => ..., 'label' => ...] where type is text, email, tel, select, radio, textarea or checkbox. Add 'placeholder', 'required' => true, 'options' (select and radio: a list of labels, or value => label pairs) and 'width' => 'half' (always half a row) or 'half-md' (half a row from md up). A checkbox takes an optional 'link' => ['label' => ..., 'href' => ...] printed after its label. Set any of email, phone or address to null to hide that item.

<x-ui.blocks.contact-10
    tagline="Support"
    heading="Talk to us"
    description="We answer every message within one working day."
    :action="route('contact.store')"
    :fields="[
        ['type' => 'text', 'name' => 'name', 'label' => 'Name', 'required' => true],
        ['type' => 'email', 'name' => 'email', 'label' => 'Email', 'required' => true],
        ['type' => 'textarea', 'name' => 'message', 'label' => 'Message', 'placeholder' => 'How can we help?'],
    ]"
    submit-label="Send message"
    email="hello@acme.test"
    phone="+61 2 5550 0000"
    address="1 Market St, Sydney NSW 2000"
/>

Props

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

@props([
    'id' => 'contact-10',
    'tagline' => 'Tagline',
    'heading' => 'Contact us',
    'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
    'action' => '#',
    'method' => 'POST',
    'csrf' => true,
    'fields' => [
        ['type' => 'text', 'name' => 'first_name', 'label' => 'First name', 'width' => 'half'],
        ['type' => 'text', 'name' => 'last_name', 'label' => 'Last name', 'width' => 'half'],
        ['type' => 'email', 'name' => 'email', 'label' => 'Email', 'width' => 'half-md'],
        ['type' => 'tel', 'name' => 'phone', 'label' => 'Phone number', 'width' => 'half-md'],
        [
            'type' => 'select',
            'name' => 'topic',
            'label' => 'Choose a topic',
            'placeholder' => 'Select one...',
            'options' => ['First topic', 'Second topic', 'Third topic'],
        ],
        [
            'type' => 'radio',
            'name' => 'role',
            'label' => 'Which best describes you?',
            'options' => ['First choice', 'Second choice', 'Third choice', 'Fourth choice', 'Fifth choice', 'Other'],
        ],
        ['type' => 'textarea', 'name' => 'message', 'label' => 'Message', 'placeholder' => 'Type your message...'],
        [
            'type' => 'checkbox',
            'name' => 'terms',
            'label' => 'I accept the',
            'link' => ['label' => 'Terms', 'href' => '#'],
            'required' => true,
        ],
    ],
    'submitLabel' => 'Submit',
    'emailTitle' => 'Email',
    'emailDescription' => 'Lorem ipsum dolor sit amet.',
    'email' => 'email@example.com',
    'phoneTitle' => 'Phone',
    'phoneDescription' => 'Lorem ipsum dolor sit amet.',
    'phone' => '+1 (555) 000-0000',
    'addressTitle' => 'Office',
    'address' => '123 Sample St, Sydney NSW 2000 AU',
    'directionsLabel' => 'Get Directions',
    'directionsHref' => null,
])