Marker map
An all-SVG harbour city with six live markers: hover swells the pin and finds its label, click opens the details popover — gradient thumbnail, rating, closing hour — and five districts light up under the pointer; not a single external tile or SDK.
Real scenarios
The component as it is used in a product — not a specimen grid.
A city you can poke
Six points of interest over a hand-drawn harbour town: hover a pin and it swells with its label, click and the details popover opens — gradient thumbnail, rating, closing hour, distance. One popover at a time; Escape folds it. The five districts light up under the pointer or from the legend chips.
The AnchorCafé
North Light GalleryGallery
Kessel RecordsVinyl shop
Botanic GlasshouseGarden
Ferry Wharf 7Transport
Aurora ViewpointViewpoint
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| markers | count | '6' | Every marker is a real button — reachable with Tab, opened with Enter, and only one popover at a time. |
| popover | state | 'click · one-open' | Clicking another marker folds the previous popover; Escape and the × button close it too. Pins near the top edge flip their popover below. |
| districts | hover | '5 areas' | Five translucent areas — Old Harbor, Old Town, Museum Mile… — that fill in on hover, on the map itself or via their legend chip. |
| thumb | gradient | 'per-poi' | The popover’s thumbnail is a two-stop gradient seeded per POI — zero image requests. |
Snippet
<div class="mpm-root" x-data="{ open: null }" x-on:keydown.escape.window="open = null">
<div class="mpm-stage" dir="ltr">
<svg class="mpm-city" viewBox="0 0 640 400" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
<path class="mpm-river" d="M-10 214 C130 192 210 252 330 232 S520 188 650 218"/>
<g class="mpm-blocks">
<rect x="40" y="44" width="110" height="78" rx="10"/>
<rect x="286" y="150" width="110" height="64" rx="10"/>
<rect x="468" y="240" width="122" height="72" rx="10"/>
</g>
<polygon class="mpm-area" points="0,96 340,120 470,230 430,300 190,330 0,290"/>
</svg>
<button type="button" class="mpm-pin" style="inset-inline-start: 24%; inset-block-start: 62%"
x-bind:aria-expanded="open === 'anchor'"
x-on:click="open = open === 'anchor' ? null : 'anchor'">
<span class="mpm-bead" aria-hidden="true"></span>
<span class="mpm-label">The Anchor · Café</span>
</button>
<div class="mpm-pop" x-cloak x-show="open === 'anchor'" style="inset-inline-start: 24%; inset-block-start: 62%">
<span class="mpm-thumb" style="background: linear-gradient(135deg, #38bdf8, #6366f1)"></span>
<b>The Anchor</b>
<small>Old Harbor · ★ 4.8 · until 22:00</small>
</div>
</div>
</div>
<style>
.mpm-root { --mpm-bg: #f6f7f9; --mpm-block: #e8eaef; --mpm-water: #cfe3f7; --mpm-line: #d4d8e0;
--mpm-accent: #4f46e5; --mpm-text: #1c1917;
font-family: 'Inter', 'Vazirmatn', ui-sans-serif, sans-serif; }
.mpm-stage { position: relative; inline-size: min(100%, 40rem); aspect-ratio: 16 / 10;
overflow: clip; border: 1px solid var(--mpm-line); border-radius: 1rem; background: var(--mpm-bg); }
.mpm-city { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.mpm-river { fill: none; stroke: var(--mpm-water); stroke-width: 26; stroke-linecap: round; }
.mpm-blocks rect { fill: var(--mpm-block); }
.mpm-area { fill: color-mix(in oklab, var(--mpm-accent) 8%, transparent); stroke: none; transition: fill .2s; }
.mpm-area:hover { fill: color-mix(in oklab, var(--mpm-accent) 20%, transparent); }
.mpm-pin { position: absolute; translate: -50% -50%; inline-size: 1.6rem; aspect-ratio: 1;
border: none; padding: 0; background: transparent; cursor: pointer; }
.mpm-bead { display: block; inline-size: 100%; aspect-ratio: 1; border-radius: 50%;
border: 3px solid #fff; background: var(--mpm-accent);
box-shadow: 0 2px 8px rgba(0, 0, 0, .18); transition: scale .2s; }
.mpm-pin:hover .mpm-bead, .mpm-pin:focus-visible .mpm-bead { scale: 1.25; }
.mpm-label { position: absolute; inset-block-end: calc(100% + .45rem); inset-inline-start: 50%;
translate: -50%; white-space: nowrap; padding: .2rem .6rem; border-radius: .6rem;
background: #fff; color: var(--mpm-text); font-size: .72rem; opacity: 0; transition: opacity .2s; }
.mpm-pin:hover .mpm-label, .mpm-pin:focus-visible .mpm-label { opacity: 1; }
.mpm-pop { position: absolute; translate: -50% calc(-100% - 1rem); inline-size: 11rem; display: grid; gap: .3rem;
padding: .6rem; border: 1px solid var(--mpm-line); border-radius: .8rem; background: #fff;
color: var(--mpm-text); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.mpm-thumb { block-size: 3.2rem; border-radius: .5rem; }
</style>
// app/Pages/CityGuide.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import CityPois from '@/components/CityPois';
export default function CityGuide() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<CityPois />
</main>
</NabuXUIProvider>
);
}
// CityPois.jsx — marker map: hover swells the pin, click opens its popover
import { useState } from 'react';
import '@nabuxai/ui-core/css';
const POIS = [
{ id: 'anchor', name: 'The Anchor', kind: 'Café', district: 'Old Harbor', rating: 4.8, until: '22:00', x: 24, y: 62, tint: ['#38bdf8', '#6366f1'] },
{ id: 'northlight', name: 'North Light Gallery', kind: 'Gallery', district: 'Museum Mile', rating: 4.9, until: '18:00', x: 58, y: 40, tint: ['#f59e0b', '#ef4444'] },
{ id: 'kessel', name: 'Kessel Records', kind: 'Vinyl', district: 'Old Town', rating: 4.6, until: '21:00', x: 44, y: 52, tint: ['#34d399', '#0ea5e9'] },
];
const BLOCKS = [[40, 44, 110, 78], [286, 150, 110, 64], [468, 240, 122, 72], [150, 146, 96, 86]];
export default function CityPois() {
const [open, setOpen] = useState(null);
return (
<>
<style>{`
.mpm-root { --mpm-bg: #f6f7f9; --mpm-block: #e8eaef; --mpm-water: #cfe3f7; --mpm-line: #d4d8e0;
--mpm-accent: #4f46e5; --mpm-text: #1c1917; font-family: 'Inter', ui-sans-serif, sans-serif; }
.mpm-stage { position: relative; inline-size: min(100%, 40rem); aspect-ratio: 16 / 10; overflow: clip;
border: 1px solid var(--mpm-line); border-radius: 1rem; background: var(--mpm-bg); }
.mpm-city { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.mpm-river { fill: none; stroke: var(--mpm-water); stroke-width: 26; stroke-linecap: round; }
.mpm-block { fill: var(--mpm-block); }
.mpm-area { fill: color-mix(in oklab, var(--mpm-accent) 8%, transparent); transition: fill .2s; }
.mpm-area:hover { fill: color-mix(in oklab, var(--mpm-accent) 20%, transparent); }
.mpm-pin { position: absolute; translate: -50% -50%; inline-size: 1.6rem; aspect-ratio: 1; border: none;
padding: 0; background: transparent; cursor: pointer; }
.mpm-bead { display: block; inline-size: 100%; aspect-ratio: 1; border-radius: 50%; border: 3px solid #fff;
background: var(--mpm-accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .18); transition: scale .2s; }
.mpm-pin:hover .mpm-bead, .mpm-pin:focus-visible .mpm-bead { scale: 1.25; }
.mpm-label { position: absolute; inset-block-end: calc(100% + .45rem); inset-inline-start: 50%; translate: -50%;
white-space: nowrap; padding: .2rem .6rem; border-radius: .6rem; background: #fff;
color: var(--mpm-text); font-size: .72rem; opacity: 0; transition: opacity .2s; }
.mpm-pin:hover .mpm-label, .mpm-pin:focus-visible .mpm-label { opacity: 1; }
.mpm-pop { position: absolute; translate: -50% calc(-100% - 1rem); inline-size: 11rem; display: grid; gap: .3rem;
padding: .6rem; border: 1px solid var(--mpm-line); border-radius: .8rem; background: #fff;
color: var(--mpm-text); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.mpm-thumb { block-size: 3.2rem; border-radius: .5rem; }
.mpm-pin:focus-visible { outline: none; }
`}</style>
<div className="mpm-root">
<div className="mpm-stage" dir="ltr" role="img" aria-label="Stylised city map with points of interest">
<svg className="mpm-city" viewBox="0 0 640 400" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
<path className="mpm-river" d="M-10 214 C130 192 210 252 330 232 S520 188 650 218" />
{BLOCKS.map(([x, y, w, h], i) => (
<rect key={i} className="mpm-block" x={x} y={y} width={w} height={h} rx="10" />
))}
<polygon className="mpm-area" points="0,96 340,120 470,230 430,300 190,330 0,290" />
</svg>
{/* One popover at a time — clicking a pin folds the previous one. */}
{POIS.map((p) => (
<div key={p.id} style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
<button type="button" className="mpm-pin" style={{ insetInlineStart: p.x + '%', insetBlockStart: p.y + '%', pointerEvents: 'auto' }}
aria-expanded={open === p.id} onClick={() => setOpen(open === p.id ? null : p.id)}>
<span className="mpm-bead" aria-hidden="true" />
<span className="mpm-label">{p.name} · {p.kind}</span>
</button>
{open === p.id && (
<div className="mpm-pop" role="dialog" aria-label={p.name}
style={{ insetInlineStart: p.x + '%', insetBlockStart: p.y + '%', pointerEvents: 'auto' }}>
<span className="mpm-thumb" style={{ background: `linear-gradient(135deg, ${p.tint[0]}, ${p.tint[1]})` }} />
<b>{p.name}</b>
<small>{p.district} · ★ {p.rating} · until {p.until}</small>
</div>
)}
</div>
))}
</div>
</div>
</>
);
}
<!-- CityPois.vue — marker map: hover swells the pin, click opens its popover -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';
interface Poi { id: string; name: string; kind: string; district: string; rating: number; until: string; x: number; y: number; tint: [string, string] }
const pois: Poi[] = [
{ id: 'anchor', name: 'The Anchor', kind: 'Café', district: 'Old Harbor', rating: 4.8, until: '22:00', x: 24, y: 62, tint: ['#38bdf8', '#6366f1'] },
{ id: 'northlight', name: 'North Light Gallery', kind: 'Gallery', district: 'Museum Mile', rating: 4.9, until: '18:00', x: 58, y: 40, tint: ['#f59e0b', '#ef4444'] },
{ id: 'kessel', name: 'Kessel Records', kind: 'Vinyl', district: 'Old Town', rating: 4.6, until: '21:00', x: 44, y: 52, tint: ['#34d399', '#0ea5e9'] },
];
const blocks = [[40, 44, 110, 78], [286, 150, 110, 64], [468, 240, 122, 72], [150, 146, 96, 86]];
const open = ref<string | null>(null);
const flip = (id: string) => { open.value = open.value === id ? null : id; };
</script>
<template>
<div class="mpm-root">
<div class="mpm-stage" dir="ltr" role="img" aria-label="Stylised city map with points of interest">
<svg class="mpm-city" viewBox="0 0 640 400" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
<path class="mpm-river" d="M-10 214 C130 192 210 252 330 232 S520 188 650 218" />
<rect v-for="([x, y, w, h], i) in blocks" :key="i" class="mpm-block" :x="x" :y="y" :width="w" :height="h" rx="10" />
<polygon class="mpm-area" points="0,96 340,120 470,230 430,300 190,330 0,290" />
</svg>
<!-- One popover at a time — clicking a pin folds the previous one. -->
<template v-for="p in pois" :key="p.id">
<button type="button" class="mpm-pin" :style="{ insetInlineStart: p.x + '%', insetBlockStart: p.y + '%' }"
:aria-expanded="open === p.id" @click="flip(p.id)">
<span class="mpm-bead" aria-hidden="true"></span>
<span class="mpm-label">{{ p.name }} · {{ p.kind }}</span>
</button>
<div v-if="open === p.id" class="mpm-pop" role="dialog" :aria-label="p.name"
:style="{ insetInlineStart: p.x + '%', insetBlockStart: p.y + '%' }">
<span class="mpm-thumb" :style="{ background: `linear-gradient(135deg, ${p.tint[0]}, ${p.tint[1]})` }"></span>
<b>{{ p.name }}</b>
<small>{{ p.district }} · ★ {{ p.rating }} · until {{ p.until }}</small>
</div>
</template>
</div>
</div>
</template>
<style scoped>
.mpm-root { --mpm-bg: #f6f7f9; --mpm-block: #e8eaef; --mpm-water: #cfe3f7; --mpm-line: #d4d8e0;
--mpm-accent: #4f46e5; --mpm-text: #1c1917; font-family: 'Inter', ui-sans-serif, sans-serif; }
.mpm-stage { position: relative; inline-size: min(100%, 40rem); aspect-ratio: 16 / 10; overflow: clip;
border: 1px solid var(--mpm-line); border-radius: 1rem; background: var(--mpm-bg); }
.mpm-city { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.mpm-river { fill: none; stroke: var(--mpm-water); stroke-width: 26; stroke-linecap: round; }
.mpm-block { fill: var(--mpm-block); }
.mpm-area { fill: color-mix(in oklab, var(--mpm-accent) 8%, transparent); transition: fill .2s; }
.mpm-area:hover { fill: color-mix(in oklab, var(--mpm-accent) 20%, transparent); }
.mpm-pin { position: absolute; translate: -50% -50%; inline-size: 1.6rem; aspect-ratio: 1; border: none;
padding: 0; background: transparent; cursor: pointer; }
.mpm-bead { display: block; inline-size: 100%; aspect-ratio: 1; border-radius: 50%; border: 3px solid #fff;
background: var(--mpm-accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .18); transition: scale .2s; }
.mpm-pin:hover .mpm-bead, .mpm-pin:focus-visible .mpm-bead { scale: 1.25; }
.mpm-label { position: absolute; inset-block-end: calc(100% + .45rem); inset-inline-start: 50%; translate: -50%;
white-space: nowrap; padding: .2rem .6rem; border-radius: .6rem; background: #fff;
color: var(--mpm-text); font-size: .72rem; opacity: 0; transition: opacity .2s; }
.mpm-pin:hover .mpm-label, .mpm-pin:focus-visible .mpm-label { opacity: 1; }
.mpm-pop { position: absolute; translate: -50% calc(-100% - 1rem); inline-size: 11rem; display: grid; gap: .3rem;
padding: .6rem; border: 1px solid var(--mpm-line); border-radius: .8rem; background: #fff;
color: var(--mpm-text); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.mpm-thumb { block-size: 3.2rem; border-radius: .5rem; }
</style>
<!-- CityPois.svelte — marker map: hover swells the pin, click opens its popover -->
<script lang="ts">
import '@nabuxai/ui-core/css';
interface Poi { id: string; name: string; kind: string; district: string; rating: number; until: string; x: number; y: number; tint: [string, string] }
const pois: Poi[] = [
{ id: 'anchor', name: 'The Anchor', kind: 'Café', district: 'Old Harbor', rating: 4.8, until: '22:00', x: 24, y: 62, tint: ['#38bdf8', '#6366f1'] },
{ id: 'northlight', name: 'North Light Gallery', kind: 'Gallery', district: 'Museum Mile', rating: 4.9, until: '18:00', x: 58, y: 40, tint: ['#f59e0b', '#ef4444'] },
{ id: 'kessel', name: 'Kessel Records', kind: 'Vinyl', district: 'Old Town', rating: 4.6, until: '21:00', x: 44, y: 52, tint: ['#34d399', '#0ea5e9'] },
];
const blocks = [[40, 44, 110, 78], [286, 150, 110, 64], [468, 240, 122, 72], [150, 146, 96, 86]];
let open = $state<string | null>(null);
const flip = (id: string) => { open = open === id ? null : id; };
</script>
<div class="mpm-root">
<div class="mpm-stage" dir="ltr" role="img" aria-label="Stylised city map with points of interest">
<svg class="mpm-city" viewBox="0 0 640 400" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
<path class="mpm-river" d="M-10 214 C130 192 210 252 330 232 S520 188 650 218" />
{#each blocks as [x, y, w, h] (`${x}-${y}`)}
<rect class="mpm-block" {x} {y} width={w} height={h} rx="10" />
{/each}
<polygon class="mpm-area" points="0,96 340,120 470,230 430,300 190,330 0,290" />
</svg>
<!-- One popover at a time — clicking a pin folds the previous one. -->
{#each pois as p (p.id)}
<button type="button" class="mpm-pin" style={`inset-inline-start: ${p.x}%; inset-block-start: ${p.y}%`}
aria-expanded={open === p.id} onclick={() => flip(p.id)}>
<span class="mpm-bead" aria-hidden="true"></span>
<span class="mpm-label">{p.name} · {p.kind}</span>
</button>
{#if open === p.id}
<div class="mpm-pop" role="dialog" aria-label={p.name}
style={`inset-inline-start: ${p.x}%; inset-block-start: ${p.y}%`}>
<span class="mpm-thumb" style={`background: linear-gradient(135deg, ${p.tint[0]}, ${p.tint[1]})`}></span>
<b>{p.name}</b>
<small>{p.district} · ★ {p.rating} · until {p.until}</small>
</div>
{/if}
{/each}
</div>
</div>
<style>
.mpm-root { --mpm-bg: #f6f7f9; --mpm-block: #e8eaef; --mpm-water: #cfe3f7; --mpm-line: #d4d8e0;
--mpm-accent: #4f46e5; --mpm-text: #1c1917; font-family: 'Inter', ui-sans-serif, sans-serif; }
.mpm-stage { position: relative; inline-size: min(100%, 40rem); aspect-ratio: 16 / 10; overflow: clip;
border: 1px solid var(--mpm-line); border-radius: 1rem; background: var(--mpm-bg); }
.mpm-city { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.mpm-river { fill: none; stroke: var(--mpm-water); stroke-width: 26; stroke-linecap: round; }
.mpm-block { fill: var(--mpm-block); }
.mpm-area { fill: color-mix(in oklab, var(--mpm-accent) 8%, transparent); transition: fill .2s; }
.mpm-area:hover { fill: color-mix(in oklab, var(--mpm-accent) 20%, transparent); }
.mpm-pin { position: absolute; translate: -50% -50%; inline-size: 1.6rem; aspect-ratio: 1; border: none;
padding: 0; background: transparent; cursor: pointer; }
.mpm-bead { display: block; inline-size: 100%; aspect-ratio: 1; border-radius: 50%; border: 3px solid #fff;
background: var(--mpm-accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .18); transition: scale .2s; }
.mpm-pin:hover .mpm-bead, .mpm-pin:focus-visible .mpm-bead { scale: 1.25; }
.mpm-label { position: absolute; inset-block-end: calc(100% + .45rem); inset-inline-start: 50%; translate: -50%;
white-space: nowrap; padding: .2rem .6rem; border-radius: .6rem; background: #fff;
color: var(--mpm-text); font-size: .72rem; opacity: 0; transition: opacity .2s; }
.mpm-pin:hover .mpm-label, .mpm-pin:focus-visible .mpm-label { opacity: 1; }
.mpm-pop { position: absolute; translate: -50% calc(-100% - 1rem); inline-size: 11rem; display: grid; gap: .3rem;
padding: .6rem; border: 1px solid var(--mpm-line); border-radius: .8rem; background: #fff;
color: var(--mpm-text); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.mpm-thumb { block-size: 3.2rem; border-radius: .5rem; }
</style>