Contact
contact-18
Locations list beside a map: pick an office from the list and its map shows next to it. CSS only, no script.
{{--
Locations list beside a map. Picking an office in the list shows its
map next to it. It works with no script: each office is a visually
hidden radio, so the list is keyboard friendly (Tab in, arrow keys to
move) and the selected map follows `:checked` in CSS. Every piece of
content is a prop. A location is ['name' => ..., 'address' => ...] plus
an optional 'map', an embed URL. No map is embedded by default: the
panel shows a placeholder until you pass 'map', which renders as a
lazy-loaded iframe titled with the location name (or 'mapTitle'). Give
each instance on a page its own `id`.
<x-ui.blocks.contact-18
id="offices"
tagline="Offices"
heading="Where to find us"
description="Pick a studio to see it on the map."
:locations="[
['name' => 'Sydney', 'address' => '1 Market St, Sydney NSW 2000', 'map' => 'https://www.openstreetmap.org/export/embed.html?bbox=151.20,-33.87,151.21,-33.86'],
['name' => 'Auckland', 'address' => '2 Queen St, Auckland 1010'],
]"
action-label="Show on map"
/>
--}}
@props([
'id' => 'contact-18',
'tagline' => 'Tagline',
'heading' => 'Locations',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'locations' => [
['name' => 'Sydney', 'address' => '123 Sample St, Sydney NSW 2000 AU'],
['name' => 'New York', 'address' => '123 Sample St, New York NY 10000 USA'],
['name' => 'London', 'address' => '123 Sample St, London W1C 1DE, United Kingdom'],
],
'actionLabel' => 'View Map',
])
<section {{ $attributes->merge(['class' => 'w-full bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto flex max-w-7xl flex-col gap-12 md:gap-20">
<div class="flex w-full max-w-3xl flex-col gap-3 md:gap-4">
@if ($tagline)
<p class="font-semibold">{{ $tagline }}</p>
@endif
<div class="flex flex-col gap-5 md:gap-6">
<h2 id="{{ $id }}-heading" class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
@if ($description)
<p class="md:text-lg">{{ $description }}</p>
@endif
</div>
</div>
{{-- The panels sit absolutely in the right column (below the list on
mobile), so each one can stay a sibling of its own radio. The
bottom padding reserves the 335:320 panel on mobile. --}}
<div class="relative pb-[calc(95.5224%+3rem)] md:min-h-[400px] md:pb-0">
<div role="radiogroup" aria-labelledby="{{ $id }}-heading"
class="flex flex-col gap-10 md:w-[calc(50%-2.5rem)] lg:w-[480px]">
@foreach ($locations as $i => $location)
@php($mapTitle = $location['mapTitle'] ?? ($location['name'] ?? 'Map'))
<div>
<x-ui.radio id="{{ $id }}-{{ $i }}" name="{{ $id }}" value="{{ $i }}"
:checked="$i === 0" class="peer sr-only" />
<label for="{{ $id }}-{{ $i }}"
class="flex cursor-pointer flex-col gap-5 border-s border-transparent ps-8 transition-colors peer-checked:border-foreground peer-focus-visible:ring-[3px] peer-focus-visible:ring-ring/50 md:gap-6">
<span class="flex flex-col gap-3 md:gap-4">
<span class="text-xl font-bold leading-[1.4] md:text-2xl">{{ $location['name'] ?? '' }}</span>
<span>{{ $location['address'] ?? '' }}</span>
</span>
@if ($actionLabel)
<span class="font-semibold">{{ $actionLabel }}</span>
@endif
</label>
<div
class="absolute inset-x-0 bottom-0 hidden aspect-[335/320] overflow-hidden bg-muted peer-checked:block md:top-0 md:start-[calc(50%+2.5rem)] md:aspect-auto lg:start-[560px]">
@if (!empty($location['map']))
<iframe src="{{ $location['map'] }}" title="{{ $mapTitle }}" loading="lazy"
referrerpolicy="no-referrer-when-downgrade" class="size-full border-0"></iframe>
@else
<div class="flex size-full items-center justify-center text-muted-foreground"
role="img" aria-label="{{ $mapTitle }}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round" class="size-12 md:size-24" 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>
</div>
@endif
</div>
</div>
@endforeach
</div>
</div>
</div>
</section>
Installation
php artisan ui:add-block contact-18
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-18
/>.
Components it includes
1. Install component dependencies
php artisan ui:add radio
2. External packages
- composer:
gehrisandro/tailwind-merge-laravel
3.
Copy the block source into
resources/views/components/ui/
resources/views/components/ui/blocks/contact-18.blade.php
{{--
Locations list beside a map. Picking an office in the list shows its
map next to it. It works with no script: each office is a visually
hidden radio, so the list is keyboard friendly (Tab in, arrow keys to
move) and the selected map follows `:checked` in CSS. Every piece of
content is a prop. A location is ['name' => ..., 'address' => ...] plus
an optional 'map', an embed URL. No map is embedded by default: the
panel shows a placeholder until you pass 'map', which renders as a
lazy-loaded iframe titled with the location name (or 'mapTitle'). Give
each instance on a page its own `id`.
<x-ui.blocks.contact-18
id="offices"
tagline="Offices"
heading="Where to find us"
description="Pick a studio to see it on the map."
:locations="[
['name' => 'Sydney', 'address' => '1 Market St, Sydney NSW 2000', 'map' => 'https://www.openstreetmap.org/export/embed.html?bbox=151.20,-33.87,151.21,-33.86'],
['name' => 'Auckland', 'address' => '2 Queen St, Auckland 1010'],
]"
action-label="Show on map"
/>
--}}
@props([
'id' => 'contact-18',
'tagline' => 'Tagline',
'heading' => 'Locations',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'locations' => [
['name' => 'Sydney', 'address' => '123 Sample St, Sydney NSW 2000 AU'],
['name' => 'New York', 'address' => '123 Sample St, New York NY 10000 USA'],
['name' => 'London', 'address' => '123 Sample St, London W1C 1DE, United Kingdom'],
],
'actionLabel' => 'View Map',
])
<section {{ $attributes->merge(['class' => 'w-full bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto flex max-w-7xl flex-col gap-12 md:gap-20">
<div class="flex w-full max-w-3xl flex-col gap-3 md:gap-4">
@if ($tagline)
<p class="font-semibold">{{ $tagline }}</p>
@endif
<div class="flex flex-col gap-5 md:gap-6">
<h2 id="{{ $id }}-heading" class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
@if ($description)
<p class="md:text-lg">{{ $description }}</p>
@endif
</div>
</div>
{{-- The panels sit absolutely in the right column (below the list on
mobile), so each one can stay a sibling of its own radio. The
bottom padding reserves the 335:320 panel on mobile. --}}
<div class="relative pb-[calc(95.5224%+3rem)] md:min-h-[400px] md:pb-0">
<div role="radiogroup" aria-labelledby="{{ $id }}-heading"
class="flex flex-col gap-10 md:w-[calc(50%-2.5rem)] lg:w-[480px]">
@foreach ($locations as $i => $location)
@php($mapTitle = $location['mapTitle'] ?? ($location['name'] ?? 'Map'))
<div>
<x-ui.radio id="{{ $id }}-{{ $i }}" name="{{ $id }}" value="{{ $i }}"
:checked="$i === 0" class="peer sr-only" />
<label for="{{ $id }}-{{ $i }}"
class="flex cursor-pointer flex-col gap-5 border-s border-transparent ps-8 transition-colors peer-checked:border-foreground peer-focus-visible:ring-[3px] peer-focus-visible:ring-ring/50 md:gap-6">
<span class="flex flex-col gap-3 md:gap-4">
<span class="text-xl font-bold leading-[1.4] md:text-2xl">{{ $location['name'] ?? '' }}</span>
<span>{{ $location['address'] ?? '' }}</span>
</span>
@if ($actionLabel)
<span class="font-semibold">{{ $actionLabel }}</span>
@endif
</label>
<div
class="absolute inset-x-0 bottom-0 hidden aspect-[335/320] overflow-hidden bg-muted peer-checked:block md:top-0 md:start-[calc(50%+2.5rem)] md:aspect-auto lg:start-[560px]">
@if (!empty($location['map']))
<iframe src="{{ $location['map'] }}" title="{{ $mapTitle }}" loading="lazy"
referrerpolicy="no-referrer-when-downgrade" class="size-full border-0"></iframe>
@else
<div class="flex size-full items-center justify-center text-muted-foreground"
role="img" aria-label="{{ $mapTitle }}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round" class="size-12 md:size-24" 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>
</div>
@endif
</div>
</div>
@endforeach
</div>
</div>
</div>
</section>
Usage
Locations list beside a map. Picking an office in the list shows its map next to it. It works with no script: each office is a visually hidden radio, so the list is keyboard friendly (Tab in, arrow keys to move) and the selected map follows `:checked` in CSS. Every piece of content is a prop. A location is ['name' => ..., 'address' => ...] plus an optional 'map', an embed URL. No map is embedded by default: the panel shows a placeholder until you pass 'map', which renders as a lazy-loaded iframe titled with the location name (or 'mapTitle'). Give each instance on a page its own `id`.
<x-ui.blocks.contact-18
id="offices"
tagline="Offices"
heading="Where to find us"
description="Pick a studio to see it on the map."
:locations="[
['name' => 'Sydney', 'address' => '1 Market St, Sydney NSW 2000', 'map' => 'https://www.openstreetmap.org/export/embed.html?bbox=151.20,-33.87,151.21,-33.86'],
['name' => 'Auckland', 'address' => '2 Queen St, Auckland 1010'],
]"
action-label="Show on map"
/>
Props
Every prop with its default. Pass any of them as attributes, using : to bind a PHP value.
@props([
'id' => 'contact-18',
'tagline' => 'Tagline',
'heading' => 'Locations',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'locations' => [
['name' => 'Sydney', 'address' => '123 Sample St, Sydney NSW 2000 AU'],
['name' => 'New York', 'address' => '123 Sample St, New York NY 10000 USA'],
['name' => 'London', 'address' => '123 Sample St, London W1C 1DE, United Kingdom'],
],
'actionLabel' => 'View Map',
])