--- title: "contact-07" description: "Two columns: heading and a short contact form, with a tall image beside it." category: "Contact" --- # contact-07 Two columns: heading and a short contact form, with a tall image beside it. ## Installation ```bash php artisan ui:add-block contact-07 ``` ## Dependencies - composer: `gehrisandro/tailwind-merge-laravel` - component: [button](https://laralcn-ui.abdulkadersafi.com/components/button.md) — the CLI installs it for you. - component: [checkbox](https://laralcn-ui.abdulkadersafi.com/components/checkbox.md) — the CLI installs it for you. - component: [input](https://laralcn-ui.abdulkadersafi.com/components/input.md) — the CLI installs it for you. - component: [label](https://laralcn-ui.abdulkadersafi.com/components/label.md) — the CLI installs it for you. - component: [textarea](https://laralcn-ui.abdulkadersafi.com/components/textarea.md) — the CLI installs it for you. ## Source `resources/views/components/ui/blocks/contact-07.blade.php` ```blade {{-- 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". --}} @props([ 'tagline' => 'Tagline', 'heading' => 'Contact us', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'action' => '#', 'method' => 'POST', 'csrf' => true, 'fields' => [ ['name' => 'name', 'label' => 'Name', 'type' => 'text', 'required' => true], ['name' => 'email', 'label' => 'Email', 'type' => 'email', 'required' => true], [ 'name' => 'message', 'label' => 'Message', 'type' => 'textarea', 'placeholder' => 'Type your message...', 'required' => true, ], ], 'terms' => 'I accept the', 'termsLink' => ['label' => 'Terms', 'href' => '#'], 'submitLabel' => 'Submit', 'image' => ['src' => null, 'alt' => ''], ]) @php // A plain form only knows GET and POST; anything else is spoofed with _method. $verb = strtoupper($method); $formMethod = $verb === 'GET' ? 'GET' : 'POST'; @endphp
merge(['class' => 'bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
@if ($tagline)

{{ $tagline }}

@endif

{{ $heading }}

@if ($description)

{{ $description }}

@endif
@if ($formMethod === 'POST') @if ($csrf) @csrf @endif @if ($verb !== 'POST') @method($verb) @endif @endif
@foreach ($fields as $field) @php $type = $field['type'] ?? 'text'; $fieldName = $field['name'] ?? 'field_' . $loop->index; $fieldId = 'contact-07-' . $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')
{{ $field['label'] ?? '' }}
@foreach ($options as $option) {{ $option['label'] }} @endforeach
@else
{{ $field['label'] ?? '' }} @if ($type === 'textarea') @elseif ($type === 'select') @foreach ($options as $option) @endforeach @else @endif
@endif @endforeach
@if ($terms) @endif {{ $submitLabel }}
@if (! empty($image['src'])) {{ $image['alt'] ?? '' }} @else
@endif
```