Contact
contact-06
Two columns: heading with email, phone and address links on one side, a long form with select and radios on the other.
{{--
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-06
tagline="Support"
heading="Get in touch"
description="We reply within one working day."
:action="route('contact.store')"
email="hello@acme.com"
phone="+61 2 9000 0000"
address="1 George St, Sydney NSW 2000"
: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([
'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',
'email' => 'email@example.com',
'phone' => '+1 (555) 000-0000',
'address' => '123 Sample St, Sydney NSW 2000 AU',
])
@php
// A plain form only knows GET and POST; anything else is spoofed with _method.
$verb = strtoupper($method);
$formMethod = $verb === 'GET' ? 'GET' : 'POST';
@endphp
<section {{ $attributes->merge(['class' => 'bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto max-w-7xl">
<div class="grid grid-cols-1 items-start gap-y-12 md:grid-cols-2 md:gap-x-12 lg:gap-x-20">
<div class="flex flex-col gap-6 md:gap-8">
<div>
@if ($tagline)
<p class="mb-3 font-semibold md:mb-4">{{ $tagline }}</p>
@endif
<h2 class="mb-5 text-4xl font-bold leading-[1.2] md:mb-6 md:text-5xl">{{ $heading }}</h2>
@if ($description)
<p class="text-muted-foreground md:text-lg">{{ $description }}</p>
@endif
</div>
<ul class="flex flex-col gap-4 py-2">
@if ($email)
<li class="flex items-start gap-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-6 shrink-0"
aria-hidden="true">
<rect width="20" height="16" x="2" y="4" rx="2" />
<path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" />
</svg>
<a href="mailto:{{ $email }}" class="break-all underline underline-offset-4">{{ $email }}</a>
</li>
@endif
@if ($phone)
<li class="flex items-start gap-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-6 shrink-0"
aria-hidden="true">
<path
d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" />
</svg>
<a href="tel:{{ preg_replace('/[^\d+]/', '', $phone) }}" dir="ltr"
class="underline underline-offset-4">{{ $phone }}</a>
</li>
@endif
@if ($address)
<li class="flex items-start gap-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-6 shrink-0"
aria-hidden="true">
<path
d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" />
<circle cx="12" cy="10" r="3" />
</svg>
<address class="not-italic">{{ $address }}</address>
</li>
@endif
</ul>
</div>
<form action="{{ $action }}" method="{{ $formMethod }}" class="flex flex-col gap-6">
@if ($formMethod === 'POST')
@if ($csrf)
@csrf
@endif
@if ($verb !== 'POST')
@method($verb)
@endif
@endif
<div class="grid grid-cols-2 gap-6">
@foreach ($fields as $field)
@php
$type = $field['type'] ?? 'text';
$fieldName = $field['name'] ?? 'field_' . $loop->index;
$fieldId = 'contact-06-' . $fieldName;
$span = match ($field['width'] ?? 'full') {
'half' => 'col-span-1',
'md:half' => 'col-span-2 md:col-span-1',
default => 'col-span-2',
};
$options = array_map(
static fn($option): array => is_array($option)
? $option + ['value' => $option['label'] ?? '']
: ['label' => $option, 'value' => $option],
$field['options'] ?? [],
);
@endphp
@if ($type === 'radio')
<div class="{{ $span }} py-4">
<fieldset>
<legend class="mb-4 text-sm font-medium">{{ $field['label'] ?? '' }}</legend>
<div class="grid grid-cols-2 gap-x-6 gap-y-3.5">
@foreach ($options as $option)
<x-ui.label class="font-normal">
<x-ui.radio name="{{ $fieldName }}" value="{{ $option['value'] }}"
:required="$field['required'] ?? false" />
{{ $option['label'] }}
</x-ui.label>
@endforeach
</div>
</fieldset>
</div>
@else
<div class="{{ $span }} flex flex-col gap-2">
<x-ui.label for="{{ $fieldId }}">{{ $field['label'] ?? '' }}</x-ui.label>
@if ($type === 'textarea')
<x-ui.textarea id="{{ $fieldId }}" name="{{ $fieldName }}"
placeholder="{{ $field['placeholder'] ?? '' }}"
:required="$field['required'] ?? false" class="min-h-45" />
@elseif ($type === 'select')
<x-ui.select id="{{ $fieldId }}" name="{{ $fieldName }}"
:required="$field['required'] ?? false">
<option value="" disabled selected>{{ $field['placeholder'] ?? '' }}</option>
@foreach ($options as $option)
<option value="{{ $option['value'] }}">{{ $option['label'] }}</option>
@endforeach
</x-ui.select>
@else
<x-ui.input type="{{ $type }}" id="{{ $fieldId }}" name="{{ $fieldName }}"
placeholder="{{ $field['placeholder'] ?? '' }}"
:required="$field['required'] ?? false" />
@endif
</div>
@endif
@endforeach
</div>
@if ($terms)
<div class="flex items-center gap-2 pb-4">
<x-ui.checkbox id="contact-06-terms" name="terms" value="1" required />
<x-ui.label for="contact-06-terms" class="font-normal">
<span>
{{ $terms }}
@if ($termsLink)
<a href="{{ is_array($termsLink) ? $termsLink['href'] ?? '#' : '#' }}"
class="underline underline-offset-4">{{ is_array($termsLink) ? $termsLink['label'] ?? '' : $termsLink }}</a>
@endif
</span>
</x-ui.label>
</div>
@endif
<x-ui.button type="submit" size="lg" class="self-start">{{ $submitLabel }}</x-ui.button>
</form>
</div>
</div>
</section>
Installation
php artisan ui:add-block contact-06
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-06
/>.
1. Install component dependencies
php artisan ui:add button checkbox input label radio select textarea
2. External packages
- composer:
gehrisandro/tailwind-merge-laravel
3.
Copy the block source into
resources/views/components/ui/
resources/views/components/ui/blocks/contact-06.blade.php
{{--
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-06
tagline="Support"
heading="Get in touch"
description="We reply within one working day."
:action="route('contact.store')"
email="hello@acme.com"
phone="+61 2 9000 0000"
address="1 George St, Sydney NSW 2000"
: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([
'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',
'email' => 'email@example.com',
'phone' => '+1 (555) 000-0000',
'address' => '123 Sample St, Sydney NSW 2000 AU',
])
@php
// A plain form only knows GET and POST; anything else is spoofed with _method.
$verb = strtoupper($method);
$formMethod = $verb === 'GET' ? 'GET' : 'POST';
@endphp
<section {{ $attributes->merge(['class' => 'bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto max-w-7xl">
<div class="grid grid-cols-1 items-start gap-y-12 md:grid-cols-2 md:gap-x-12 lg:gap-x-20">
<div class="flex flex-col gap-6 md:gap-8">
<div>
@if ($tagline)
<p class="mb-3 font-semibold md:mb-4">{{ $tagline }}</p>
@endif
<h2 class="mb-5 text-4xl font-bold leading-[1.2] md:mb-6 md:text-5xl">{{ $heading }}</h2>
@if ($description)
<p class="text-muted-foreground md:text-lg">{{ $description }}</p>
@endif
</div>
<ul class="flex flex-col gap-4 py-2">
@if ($email)
<li class="flex items-start gap-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-6 shrink-0"
aria-hidden="true">
<rect width="20" height="16" x="2" y="4" rx="2" />
<path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" />
</svg>
<a href="mailto:{{ $email }}" class="break-all underline underline-offset-4">{{ $email }}</a>
</li>
@endif
@if ($phone)
<li class="flex items-start gap-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-6 shrink-0"
aria-hidden="true">
<path
d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" />
</svg>
<a href="tel:{{ preg_replace('/[^\d+]/', '', $phone) }}" dir="ltr"
class="underline underline-offset-4">{{ $phone }}</a>
</li>
@endif
@if ($address)
<li class="flex items-start gap-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-6 shrink-0"
aria-hidden="true">
<path
d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" />
<circle cx="12" cy="10" r="3" />
</svg>
<address class="not-italic">{{ $address }}</address>
</li>
@endif
</ul>
</div>
<form action="{{ $action }}" method="{{ $formMethod }}" class="flex flex-col gap-6">
@if ($formMethod === 'POST')
@if ($csrf)
@csrf
@endif
@if ($verb !== 'POST')
@method($verb)
@endif
@endif
<div class="grid grid-cols-2 gap-6">
@foreach ($fields as $field)
@php
$type = $field['type'] ?? 'text';
$fieldName = $field['name'] ?? 'field_' . $loop->index;
$fieldId = 'contact-06-' . $fieldName;
$span = match ($field['width'] ?? 'full') {
'half' => 'col-span-1',
'md:half' => 'col-span-2 md:col-span-1',
default => 'col-span-2',
};
$options = array_map(
static fn($option): array => is_array($option)
? $option + ['value' => $option['label'] ?? '']
: ['label' => $option, 'value' => $option],
$field['options'] ?? [],
);
@endphp
@if ($type === 'radio')
<div class="{{ $span }} py-4">
<fieldset>
<legend class="mb-4 text-sm font-medium">{{ $field['label'] ?? '' }}</legend>
<div class="grid grid-cols-2 gap-x-6 gap-y-3.5">
@foreach ($options as $option)
<x-ui.label class="font-normal">
<x-ui.radio name="{{ $fieldName }}" value="{{ $option['value'] }}"
:required="$field['required'] ?? false" />
{{ $option['label'] }}
</x-ui.label>
@endforeach
</div>
</fieldset>
</div>
@else
<div class="{{ $span }} flex flex-col gap-2">
<x-ui.label for="{{ $fieldId }}">{{ $field['label'] ?? '' }}</x-ui.label>
@if ($type === 'textarea')
<x-ui.textarea id="{{ $fieldId }}" name="{{ $fieldName }}"
placeholder="{{ $field['placeholder'] ?? '' }}"
:required="$field['required'] ?? false" class="min-h-45" />
@elseif ($type === 'select')
<x-ui.select id="{{ $fieldId }}" name="{{ $fieldName }}"
:required="$field['required'] ?? false">
<option value="" disabled selected>{{ $field['placeholder'] ?? '' }}</option>
@foreach ($options as $option)
<option value="{{ $option['value'] }}">{{ $option['label'] }}</option>
@endforeach
</x-ui.select>
@else
<x-ui.input type="{{ $type }}" id="{{ $fieldId }}" name="{{ $fieldName }}"
placeholder="{{ $field['placeholder'] ?? '' }}"
:required="$field['required'] ?? false" />
@endif
</div>
@endif
@endforeach
</div>
@if ($terms)
<div class="flex items-center gap-2 pb-4">
<x-ui.checkbox id="contact-06-terms" name="terms" value="1" required />
<x-ui.label for="contact-06-terms" class="font-normal">
<span>
{{ $terms }}
@if ($termsLink)
<a href="{{ is_array($termsLink) ? $termsLink['href'] ?? '#' : '#' }}"
class="underline underline-offset-4">{{ is_array($termsLink) ? $termsLink['label'] ?? '' : $termsLink }}</a>
@endif
</span>
</x-ui.label>
</div>
@endif
<x-ui.button type="submit" size="lg" class="self-start">{{ $submitLabel }}</x-ui.button>
</form>
</div>
</div>
</section>
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-06
tagline="Support"
heading="Get in touch"
description="We reply within one working day."
:action="route('contact.store')"
email="hello@acme.com"
phone="+61 2 9000 0000"
address="1 George St, Sydney NSW 2000"
: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',
'email' => 'email@example.com',
'phone' => '+1 (555) 000-0000',
'address' => '123 Sample St, Sydney NSW 2000 AU',
])