# Route options on a map

> Three possible routes on a small map: the chosen one is drawn in colour from end to end and the rest stay dotted.

- Category: [Radio buttons](https://library.aimran.es/components/radios)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-rd-route-map
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

This radio group pairs three route cards with an inline SVG map of streets, parks and a river. Choosing a card draws its path in the accent colour from start to finish, while the other routes stay as thin dotted lines. Land, parks and water mix with the page colours, so it works in light and dark themes for delivery, travel and fitness apps.

The main color marks the active route and the destination pin, the secondary color the parks and the start point. Edit the three path shapes in the SVG to match your own map, and keep each card to a time, a short name and a distance.

## Code

### HTML

```html
<fieldset class="uvq04-map"><legend>Choose a route</legend><div class="mp" aria-hidden="true"><svg viewBox="0 0 200 100" preserveAspectRatio="xMidYMid slice"><rect class="ld" width="200" height="100"/><path class="pk" d="M128 60c14-8 34-6 40 6s-8 26-26 24-26-22-14-30z"/><path class="pk" d="M30 18c10-8 28-4 30 6s-12 18-24 14-14-14-6-20z"/><path class="st" d="M0 52H200M0 30H200M62 0V100M112 0V100M150 0V100M0 80H200"/><path class="rv" d="M-5 72C35 52 50 64 72 49S102 24 128 32S166 24 205 8"/><path class="r r1" pathLength="100" d="M22 80C60 98 96 92 122 70S166 42 178 22"/><path class="r r2" pathLength="100" d="M22 80H62V52H112V30H170L178 22"/><path class="r r3" pathLength="100" d="M22 80C40 60 56 70 76 55S106 30 130 37S164 30 178 22"/><circle class="pa" cx="22" cy="80" r="5"/><circle class="pb" cx="178" cy="22" r="6"/><circle class="pc" cx="178" cy="22" r="2.4"/></svg></div><div class="op"><label><input type="radio" name="uvq04-map" checked><span class="cd"><b>18 min</b><span>Via the motorway</span><small>6,2 km</small></span></label><label><input type="radio" name="uvq04-map"><span class="cd"><b>24 min</b><span>Through the centre</span><small>4,8 km</small></span></label><label><input type="radio" name="uvq04-map"><span class="cd"><b>27 min</b><span>Along the river</span><small>5,5 km</small></span></label></div></fieldset>
```

### CSS

```css
.uvq04-map {
  --c1: #e8590c;
  --c2: #2f9e44;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq04-map {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  width: 19em;
}

.uvq04-map legend {
  padding: 0;
  margin: 0 0 .8em;
  font-weight: 700;
}

.uvq04-map .mp {
  height: 9.5em;
  border-radius: 1em;
  overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1em 2em -1.4em rgba(0,0,0,.5);
}

.uvq04-map svg {
  display: block;
  width: 100%;
  height: 100%;
}

.uvq04-map .ld {
  fill: color-mix(in srgb,var(--fg) 5%,var(--bg));
}

.uvq04-map .pk {
  fill: color-mix(in srgb,var(--c2) 22%,var(--bg));
}

.uvq04-map .st {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 9%,var(--bg));
  stroke-width: 3;
}

.uvq04-map .rv {
  fill: none;
  stroke: color-mix(in srgb,#3a8ee6 32%,var(--bg));
  stroke-width: 7;
  stroke-linecap: round;
}

.uvq04-map .r {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 30%,transparent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2 3.5;
  transition: stroke calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),stroke-width calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-map .pa {
  fill: var(--c2);
  stroke: var(--bg);
  stroke-width: 2;
}

.uvq04-map .pb {
  fill: var(--c1);
  stroke: var(--bg);
  stroke-width: 2;
}

.uvq04-map .pc {
  fill: var(--bg);
}

.uvq04-map .op {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .45em;
  margin-top: .6em;
}

.uvq04-map label {
  position: relative;
  cursor: pointer;
}

.uvq04-map input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq04-map .cd {
  display: flex;
  flex-direction: column;
  gap: .15em;
  height: 100%;
  box-sizing: border-box;
  padding: .55em .6em;
  border-radius: .7em;
  font-size: .82em;
  background: color-mix(in srgb,var(--fg) 4%,transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--fg) 10%,transparent);
  transition: all calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-map .cd b {
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.uvq04-map .cd span {
  line-height: 1.2;
}

.uvq04-map .cd small {
  font-size: .82em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq04-map label:hover .cd {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq04-map label:active .cd {
  transform: scale(.97);
}

.uvq04-map input:checked + .cd {
  background: color-mix(in srgb,var(--c1) 10%,transparent);
  box-shadow: inset 0 0 0 2px var(--c1);
}

.uvq04-map input:checked + .cd b {
  color: var(--c1);
}

.uvq04-map input:focus-visible + .cd {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq04-map:has(label:nth-of-type(1) input:checked) .r1 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

.uvq04-map:has(label:nth-of-type(2) input:checked) .r2 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

.uvq04-map:has(label:nth-of-type(3) input:checked) .r3 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

@keyframes uvq04-map {
  from {
    stroke-dashoffset: 100;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq04-map,.uvq04-map *,.uvq04-map *::before,.uvq04-map *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### React

```tsx
import type { CSSProperties } from "react";

const css = `
.uvq04-map {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  width: 19em;
}

.uvq04-map legend {
  padding: 0;
  margin: 0 0 .8em;
  font-weight: 700;
}

.uvq04-map .mp {
  height: 9.5em;
  border-radius: 1em;
  overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1em 2em -1.4em rgba(0,0,0,.5);
}

.uvq04-map svg {
  display: block;
  width: 100%;
  height: 100%;
}

.uvq04-map .ld {
  fill: color-mix(in srgb,var(--fg) 5%,var(--bg));
}

.uvq04-map .pk {
  fill: color-mix(in srgb,var(--c2) 22%,var(--bg));
}

.uvq04-map .st {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 9%,var(--bg));
  stroke-width: 3;
}

.uvq04-map .rv {
  fill: none;
  stroke: color-mix(in srgb,#3a8ee6 32%,var(--bg));
  stroke-width: 7;
  stroke-linecap: round;
}

.uvq04-map .r {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 30%,transparent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2 3.5;
  transition: stroke calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),stroke-width calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-map .pa {
  fill: var(--c2);
  stroke: var(--bg);
  stroke-width: 2;
}

.uvq04-map .pb {
  fill: var(--c1);
  stroke: var(--bg);
  stroke-width: 2;
}

.uvq04-map .pc {
  fill: var(--bg);
}

.uvq04-map .op {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .45em;
  margin-top: .6em;
}

.uvq04-map label {
  position: relative;
  cursor: pointer;
}

.uvq04-map input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq04-map .cd {
  display: flex;
  flex-direction: column;
  gap: .15em;
  height: 100%;
  box-sizing: border-box;
  padding: .55em .6em;
  border-radius: .7em;
  font-size: .82em;
  background: color-mix(in srgb,var(--fg) 4%,transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--fg) 10%,transparent);
  transition: all calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-map .cd b {
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.uvq04-map .cd span {
  line-height: 1.2;
}

.uvq04-map .cd small {
  font-size: .82em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq04-map label:hover .cd {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq04-map label:active .cd {
  transform: scale(.97);
}

.uvq04-map input:checked + .cd {
  background: color-mix(in srgb,var(--c1) 10%,transparent);
  box-shadow: inset 0 0 0 2px var(--c1);
}

.uvq04-map input:checked + .cd b {
  color: var(--c1);
}

.uvq04-map input:focus-visible + .cd {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq04-map:has(label:nth-of-type(1) input:checked) .r1 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

.uvq04-map:has(label:nth-of-type(2) input:checked) .r2 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

.uvq04-map:has(label:nth-of-type(3) input:checked) .r3 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

@keyframes uvq04-map {
  from {
    stroke-dashoffset: 100;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq04-map,.uvq04-map *,.uvq04-map *::before,.uvq04-map *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

export default function RdRouteMap() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e8590c",
          "--c2": "#2f9e44",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <fieldset className="uvq04-map"><legend>Choose a route</legend><div className="mp" aria-hidden="true"><svg viewBox="0 0 200 100" preserveAspectRatio="xMidYMid slice"><rect className="ld" width="200" height="100" /><path className="pk" d="M128 60c14-8 34-6 40 6s-8 26-26 24-26-22-14-30z" /><path className="pk" d="M30 18c10-8 28-4 30 6s-12 18-24 14-14-14-6-20z" /><path className="st" d="M0 52H200M0 30H200M62 0V100M112 0V100M150 0V100M0 80H200" /><path className="rv" d="M-5 72C35 52 50 64 72 49S102 24 128 32S166 24 205 8" /><path className="r r1" pathLength="100" d="M22 80C60 98 96 92 122 70S166 42 178 22" /><path className="r r2" pathLength="100" d="M22 80H62V52H112V30H170L178 22" /><path className="r r3" pathLength="100" d="M22 80C40 60 56 70 76 55S106 30 130 37S164 30 178 22" /><circle className="pa" cx="22" cy="80" r="5" /><circle className="pb" cx="178" cy="22" r="6" /><circle className="pc" cx="178" cy="22" r="2.4" /></svg></div><div className="op"><label><input type="radio" name="uvq04-map" checked={true} /><span className="cd"><b>18 min</b><span>Via the motorway</span><small>6,2 km</small></span></label><label><input type="radio" name="uvq04-map" /><span className="cd"><b>24 min</b><span>Through the centre</span><small>4,8 km</small></span></label><label><input type="radio" name="uvq04-map" /><span className="cd"><b>27 min</b><span>Along the river</span><small>5,5 km</small></span></label></div></fieldset>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Route options on a map” block (Radio buttons) from AIMRAN Library to my project.

## What it is
Three possible routes on a small map: the chosen one is drawn in colour from end to end and the rest stay dotted.

## Chosen settings
- Main color: #e8590c
- Secondary color: #2f9e44
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Elige una ruta"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
import type { CSSProperties } from "react";

const css = `
.uvq04-map {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  width: 19em;
}

.uvq04-map legend {
  padding: 0;
  margin: 0 0 .8em;
  font-weight: 700;
}

.uvq04-map .mp {
  height: 9.5em;
  border-radius: 1em;
  overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1em 2em -1.4em rgba(0,0,0,.5);
}

.uvq04-map svg {
  display: block;
  width: 100%;
  height: 100%;
}

.uvq04-map .ld {
  fill: color-mix(in srgb,var(--fg) 5%,var(--bg));
}

.uvq04-map .pk {
  fill: color-mix(in srgb,var(--c2) 22%,var(--bg));
}

.uvq04-map .st {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 9%,var(--bg));
  stroke-width: 3;
}

.uvq04-map .rv {
  fill: none;
  stroke: color-mix(in srgb,#3a8ee6 32%,var(--bg));
  stroke-width: 7;
  stroke-linecap: round;
}

.uvq04-map .r {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 30%,transparent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2 3.5;
  transition: stroke calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),stroke-width calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-map .pa {
  fill: var(--c2);
  stroke: var(--bg);
  stroke-width: 2;
}

.uvq04-map .pb {
  fill: var(--c1);
  stroke: var(--bg);
  stroke-width: 2;
}

.uvq04-map .pc {
  fill: var(--bg);
}

.uvq04-map .op {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .45em;
  margin-top: .6em;
}

.uvq04-map label {
  position: relative;
  cursor: pointer;
}

.uvq04-map input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq04-map .cd {
  display: flex;
  flex-direction: column;
  gap: .15em;
  height: 100%;
  box-sizing: border-box;
  padding: .55em .6em;
  border-radius: .7em;
  font-size: .82em;
  background: color-mix(in srgb,var(--fg) 4%,transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--fg) 10%,transparent);
  transition: all calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-map .cd b {
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.uvq04-map .cd span {
  line-height: 1.2;
}

.uvq04-map .cd small {
  font-size: .82em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq04-map label:hover .cd {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq04-map label:active .cd {
  transform: scale(.97);
}

.uvq04-map input:checked + .cd {
  background: color-mix(in srgb,var(--c1) 10%,transparent);
  box-shadow: inset 0 0 0 2px var(--c1);
}

.uvq04-map input:checked + .cd b {
  color: var(--c1);
}

.uvq04-map input:focus-visible + .cd {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq04-map:has(label:nth-of-type(1) input:checked) .r1 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

.uvq04-map:has(label:nth-of-type(2) input:checked) .r2 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

.uvq04-map:has(label:nth-of-type(3) input:checked) .r3 {
  stroke: var(--c1);
  stroke-width: 4;
  stroke-dasharray: 100;
  animation: uvq04-map calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1) both;
}

@keyframes uvq04-map {
  from {
    stroke-dashoffset: 100;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq04-map,.uvq04-map *,.uvq04-map *::before,.uvq04-map *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

export default function RdRouteMap() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e8590c",
          "--c2": "#2f9e44",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <fieldset className="uvq04-map"><legend>Choose a route</legend><div className="mp" aria-hidden="true"><svg viewBox="0 0 200 100" preserveAspectRatio="xMidYMid slice"><rect className="ld" width="200" height="100" /><path className="pk" d="M128 60c14-8 34-6 40 6s-8 26-26 24-26-22-14-30z" /><path className="pk" d="M30 18c10-8 28-4 30 6s-12 18-24 14-14-14-6-20z" /><path className="st" d="M0 52H200M0 30H200M62 0V100M112 0V100M150 0V100M0 80H200" /><path className="rv" d="M-5 72C35 52 50 64 72 49S102 24 128 32S166 24 205 8" /><path className="r r1" pathLength="100" d="M22 80C60 98 96 92 122 70S166 42 178 22" /><path className="r r2" pathLength="100" d="M22 80H62V52H112V30H170L178 22" /><path className="r r3" pathLength="100" d="M22 80C40 60 56 70 76 55S106 30 130 37S164 30 178 22" /><circle className="pa" cx="22" cy="80" r="5" /><circle className="pb" cx="178" cy="22" r="6" /><circle className="pc" cx="178" cy="22" r="2.4" /></svg></div><div className="op"><label><input type="radio" name="uvq04-map" checked={true} /><span className="cd"><b>18 min</b><span>Via the motorway</span><small>6,2 km</small></span></label><label><input type="radio" name="uvq04-map" /><span className="cd"><b>24 min</b><span>Through the centre</span><small>4,8 km</small></span></label><label><input type="radio" name="uvq04-map" /><span className="cd"><b>27 min</b><span>Along the river</span><small>5,5 km</small></span></label></div></fieldset>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
