# Drive mode selector toggle

> A car cluster switches from ECO to SPORT: the needle climbs, the arc turns red and the panel shakes.

- Category: [Toggles](https://library.aimran.es/components/toggles)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-tg-drive-mode
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Borrowed from modern car dashboards, this switch is a small dark cluster with an arc gauge and a needle. Off, it sits in ECO with a short green arc; on, the needle sweeps up, the arc grows and turns red, SPORT slides in under the gauge, and the panel gives a brief rumble. The gauge is an inline SVG with pathLength, so the arc fill is easy to tune.

The main color is the sport state and the second one the eco state. Rename the two modes in the HTML, for example COMFORT and TRACK, and use it for performance modes, power plans or boost features.

## Code

### HTML

```html
<label class="uvq03-drv"><input type="checkbox" role="switch"><span class="cl"><svg viewBox="0 12 100 50" aria-hidden="true"><path class="tk" d="M12 56A38 38 0 0 1 88 56" pathLength="1"/><path class="ar" d="M12 56A38 38 0 0 1 88 56" pathLength="1"/><g class="nd"><path d="M50 56L50 24"/><circle cx="50" cy="56" r="4"/></g></svg><span class="md"><b class="e">ECO</b><b class="s">SPORT</b></span></span>Drive mode</label>
```

### CSS

```css
.uvq03-drv {
  --c1: #ff3b30;
  --c2: #30d158;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq03-drv {
  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;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

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

.uvq03-drv .cl {
  position: relative;
  display: grid;
  justify-items: center;
  flex: none;
  width: 5.2em;
  padding: .55em .55em .5em;
  box-sizing: border-box;
  border-radius: 1em;
  background: radial-gradient(120% 90% at 50% 100%,color-mix(in srgb,var(--c2) 18%,#101114),#0b0c0e 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08),0 .6em 1.2em -.6em rgba(0,0,0,.7);
}

.uvq03-drv .cl::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(110% 85% at 50% 100%,color-mix(in srgb,var(--c1) 38%,transparent),transparent 70%);
  opacity: 0;
  transition: opacity calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv svg {
  position: relative;
  display: block;
  width: 100%;
  overflow: visible;
}

.uvq03-drv .tk,.uvq03-drv .ar {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

.uvq03-drv .tk {
  stroke: #2a2c31;
}

.uvq03-drv .ar {
  stroke: var(--c2);
  stroke-dasharray: 1;
  stroke-dashoffset: .72;
  filter: drop-shadow(0 0 3px var(--c2));
  transition: stroke-dashoffset calc(0.8s / var(--k)) cubic-bezier(.22,1,.36,1),stroke calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv .nd {
  transform-origin: 50px 56px;
  transform: rotate(-40deg);
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-drv .nd path {
  stroke: #f4f4f4;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.uvq03-drv .nd circle {
  fill: #f4f4f4;
}

.uvq03-drv .md {
  position: relative;
  display: grid;
  margin-top: .15em;
  font: 800 .62em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  letter-spacing: .22em;
}

.uvq03-drv .md b {
  grid-area: 1/1;
  text-align: center;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv .e {
  color: var(--c2);
}

.uvq03-drv .s {
  color: var(--c1);
  opacity: 0;
  transform: translateY(.5em);
}

.uvq03-drv:hover input:not(:checked) + .cl .nd {
  transform: rotate(-26deg);
}

.uvq03-drv:active .cl {
  scale: .97;
}

.uvq03-drv input:checked + .cl {
  animation: uvq03-drv calc(0.06s / var(--k)) linear 6 alternate calc(0.25s / var(--k));
}

.uvq03-drv input:checked + .cl::before {
  opacity: 1;
}

.uvq03-drv input:checked + .cl .ar {
  stroke: var(--c1);
  stroke-dashoffset: .1;
  filter: drop-shadow(0 0 4px var(--c1));
}

.uvq03-drv input:checked + .cl .nd {
  transform: rotate(70deg);
}

.uvq03-drv input:checked + .cl .e {
  opacity: 0;
  transform: translateY(-.5em);
}

.uvq03-drv input:checked + .cl .s {
  opacity: 1;
  transform: none;
}

@keyframes uvq03-drv {
  from {
    translate: -.03em 0;
  }
  to {
    translate: .03em .02em;
  }
}

.uvq03-drv input:focus-visible + .cl {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

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

### React

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

const css = `
.uvq03-drv {
  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;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

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

.uvq03-drv .cl {
  position: relative;
  display: grid;
  justify-items: center;
  flex: none;
  width: 5.2em;
  padding: .55em .55em .5em;
  box-sizing: border-box;
  border-radius: 1em;
  background: radial-gradient(120% 90% at 50% 100%,color-mix(in srgb,var(--c2) 18%,#101114),#0b0c0e 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08),0 .6em 1.2em -.6em rgba(0,0,0,.7);
}

.uvq03-drv .cl::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(110% 85% at 50% 100%,color-mix(in srgb,var(--c1) 38%,transparent),transparent 70%);
  opacity: 0;
  transition: opacity calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv svg {
  position: relative;
  display: block;
  width: 100%;
  overflow: visible;
}

.uvq03-drv .tk,.uvq03-drv .ar {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

.uvq03-drv .tk {
  stroke: #2a2c31;
}

.uvq03-drv .ar {
  stroke: var(--c2);
  stroke-dasharray: 1;
  stroke-dashoffset: .72;
  filter: drop-shadow(0 0 3px var(--c2));
  transition: stroke-dashoffset calc(0.8s / var(--k)) cubic-bezier(.22,1,.36,1),stroke calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv .nd {
  transform-origin: 50px 56px;
  transform: rotate(-40deg);
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-drv .nd path {
  stroke: #f4f4f4;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.uvq03-drv .nd circle {
  fill: #f4f4f4;
}

.uvq03-drv .md {
  position: relative;
  display: grid;
  margin-top: .15em;
  font: 800 .62em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  letter-spacing: .22em;
}

.uvq03-drv .md b {
  grid-area: 1/1;
  text-align: center;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv .e {
  color: var(--c2);
}

.uvq03-drv .s {
  color: var(--c1);
  opacity: 0;
  transform: translateY(.5em);
}

.uvq03-drv:hover input:not(:checked) + .cl .nd {
  transform: rotate(-26deg);
}

.uvq03-drv:active .cl {
  scale: .97;
}

.uvq03-drv input:checked + .cl {
  animation: uvq03-drv calc(0.06s / var(--k)) linear 6 alternate calc(0.25s / var(--k));
}

.uvq03-drv input:checked + .cl::before {
  opacity: 1;
}

.uvq03-drv input:checked + .cl .ar {
  stroke: var(--c1);
  stroke-dashoffset: .1;
  filter: drop-shadow(0 0 4px var(--c1));
}

.uvq03-drv input:checked + .cl .nd {
  transform: rotate(70deg);
}

.uvq03-drv input:checked + .cl .e {
  opacity: 0;
  transform: translateY(-.5em);
}

.uvq03-drv input:checked + .cl .s {
  opacity: 1;
  transform: none;
}

@keyframes uvq03-drv {
  from {
    translate: -.03em 0;
  }
  to {
    translate: .03em .02em;
  }
}

.uvq03-drv input:focus-visible + .cl {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

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

export default function TgDriveMode() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#ff3b30",
          "--c2": "#30d158",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-drv"><input type="checkbox" role="switch" /><span className="cl"><svg viewBox="0 12 100 50" aria-hidden="true"><path className="tk" d="M12 56A38 38 0 0 1 88 56" pathLength="1" /><path className="ar" d="M12 56A38 38 0 0 1 88 56" pathLength="1" /><g className="nd"><path d="M50 56L50 24" /><circle cx="50" cy="56" r="4" /></g></svg><span className="md"><b className="e">ECO</b><b className="s">SPORT</b></span></span>Drive mode</label>
      </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 “Drive mode selector toggle” block (Toggles) from AIMRAN Library to my project.

## What it is
A car cluster switches from ECO to SPORT: the needle climbs, the arc turns red and the panel shakes.

## Chosen settings
- Main color: #ff3b30
- Secondary color: #30d158
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Modo de conducción"

## 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 = `
.uvq03-drv {
  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;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

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

.uvq03-drv .cl {
  position: relative;
  display: grid;
  justify-items: center;
  flex: none;
  width: 5.2em;
  padding: .55em .55em .5em;
  box-sizing: border-box;
  border-radius: 1em;
  background: radial-gradient(120% 90% at 50% 100%,color-mix(in srgb,var(--c2) 18%,#101114),#0b0c0e 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08),0 .6em 1.2em -.6em rgba(0,0,0,.7);
}

.uvq03-drv .cl::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(110% 85% at 50% 100%,color-mix(in srgb,var(--c1) 38%,transparent),transparent 70%);
  opacity: 0;
  transition: opacity calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv svg {
  position: relative;
  display: block;
  width: 100%;
  overflow: visible;
}

.uvq03-drv .tk,.uvq03-drv .ar {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

.uvq03-drv .tk {
  stroke: #2a2c31;
}

.uvq03-drv .ar {
  stroke: var(--c2);
  stroke-dasharray: 1;
  stroke-dashoffset: .72;
  filter: drop-shadow(0 0 3px var(--c2));
  transition: stroke-dashoffset calc(0.8s / var(--k)) cubic-bezier(.22,1,.36,1),stroke calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv .nd {
  transform-origin: 50px 56px;
  transform: rotate(-40deg);
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-drv .nd path {
  stroke: #f4f4f4;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.uvq03-drv .nd circle {
  fill: #f4f4f4;
}

.uvq03-drv .md {
  position: relative;
  display: grid;
  margin-top: .15em;
  font: 800 .62em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  letter-spacing: .22em;
}

.uvq03-drv .md b {
  grid-area: 1/1;
  text-align: center;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-drv .e {
  color: var(--c2);
}

.uvq03-drv .s {
  color: var(--c1);
  opacity: 0;
  transform: translateY(.5em);
}

.uvq03-drv:hover input:not(:checked) + .cl .nd {
  transform: rotate(-26deg);
}

.uvq03-drv:active .cl {
  scale: .97;
}

.uvq03-drv input:checked + .cl {
  animation: uvq03-drv calc(0.06s / var(--k)) linear 6 alternate calc(0.25s / var(--k));
}

.uvq03-drv input:checked + .cl::before {
  opacity: 1;
}

.uvq03-drv input:checked + .cl .ar {
  stroke: var(--c1);
  stroke-dashoffset: .1;
  filter: drop-shadow(0 0 4px var(--c1));
}

.uvq03-drv input:checked + .cl .nd {
  transform: rotate(70deg);
}

.uvq03-drv input:checked + .cl .e {
  opacity: 0;
  transform: translateY(-.5em);
}

.uvq03-drv input:checked + .cl .s {
  opacity: 1;
  transform: none;
}

@keyframes uvq03-drv {
  from {
    translate: -.03em 0;
  }
  to {
    translate: .03em .02em;
  }
}

.uvq03-drv input:focus-visible + .cl {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

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

export default function TgDriveMode() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#ff3b30",
          "--c2": "#30d158",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-drv"><input type="checkbox" role="switch" /><span className="cl"><svg viewBox="0 12 100 50" aria-hidden="true"><path className="tk" d="M12 56A38 38 0 0 1 88 56" pathLength="1" /><path className="ar" d="M12 56A38 38 0 0 1 88 56" pathLength="1" /><g className="nd"><path d="M50 56L50 24" /><circle cx="50" cy="56" r="4" /></g></svg><span className="md"><b className="e">ECO</b><b className="s">SPORT</b></span></span>Drive mode</label>
      </div>
    </>
  );
}
```

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