# Automatic gear selector radio

> An automatic gear lever slides along the P, R, N, D gate and the chosen letter lights up in amber.

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

## Where to use it

This radio group borrows the shifter from an automatic car: four real radio inputs sit next to a dark gate, and a round knob slides to the chosen position while its letter glows like a dashboard backlight. It is plain CSS driven by :has, so it suits car configurators, driving apps, playful settings panels and any mode switch with a fixed order.

Change the amber glow with the main color and the console tone with the secondary one. Rename the four modes to fit your product, such as eco, comfort, sport and track, and keep labels short so the rows stay aligned.

## Code

### HTML

```html
<fieldset class="uvq04-gear"><legend>Gear</legend><div class="pn"><span class="gt" aria-hidden="true"><i class="kb"></i></span><div class="ls"><label><input type="radio" name="uvq04-gear" checked><b>P</b><span>Park</span></label><label><input type="radio" name="uvq04-gear"><b>R</b><span>Reverse</span></label><label><input type="radio" name="uvq04-gear"><b>N</b><span>Neutral</span></label><label><input type="radio" name="uvq04-gear"><b>D</b><span>Drive</span></label></div></div></fieldset>
```

### CSS

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

.uvq04-gear {
  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;
}

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

.uvq04-gear .pn {
  display: flex;
  gap: .6em;
  padding: 1em 1.3em 1em .9em;
  border-radius: 1.3em;
  color: #e4e6ea;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c2),#fff 12%),color-mix(in srgb,var(--c2),#000 45%));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14),inset 0 -.2em .5em rgba(0,0,0,.4),0 1.4em 2.4em -1.2em rgba(0,0,0,.7);
}

.uvq04-gear .gt {
  position: relative;
  width: .9em;
  margin: .2em .8em;
  border-radius: 1em;
  background: #08090b;
  box-shadow: inset 0 .2em .35em #000,0 1px 0 rgba(255,255,255,.12);
}

.uvq04-gear .kb {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2.3em;
  height: 2.3em;
  margin: -.15em 0 0 -1.15em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%,#8a909b,#363a42 55%,#16181c);
  box-shadow: 0 .5em .9em -.1em rgba(0,0,0,.75),inset 0 1px 1px rgba(255,255,255,.35);
  transform: translateY(calc(var(--g,0) * 2.6em));
  transition: transform calc(0.55s / var(--k)) cubic-bezier(.4,1.5,.5,1);
}

.uvq04-gear .kb::after {
  content: var(--l,"P");
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: .8em;
  font-weight: 800;
  color: var(--c1);
  text-shadow: 0 0 .5em var(--c1);
}

.uvq04-gear .ls {
  display: grid;
  gap: .2em;
}

.uvq04-gear label {
  position: relative;
  display: flex;
  align-items: center;
  gap: .8em;
  height: 2.4em;
  padding: 0 .8em 0 .5em;
  border-radius: .7em;
  cursor: pointer;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

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

.uvq04-gear b {
  width: 1em;
  font-size: 1.55em;
  font-weight: 800;
  text-align: center;
  color: #5b6069;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),text-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-gear label span {
  font-size: .8em;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  color: #868b94;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-gear label:hover {
  background: rgba(255,255,255,.05);
}

.uvq04-gear label:hover b {
  color: #9aa0aa;
}

.uvq04-gear label:active {
  background: rgba(255,255,255,.1);
}

.uvq04-gear input:checked + b {
  color: var(--c1);
  text-shadow: 0 0 .35em var(--c1),0 0 1.2em color-mix(in srgb,var(--c1) 60%,transparent);
}

.uvq04-gear input:checked ~ span {
  color: #f2f3f5;
}

.uvq04-gear label:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq04-gear:has(label:nth-of-type(1) input:checked) .kb {
  --g: 0;
  --l: "P";
}

.uvq04-gear:has(label:nth-of-type(2) input:checked) .kb {
  --g: 1;
  --l: "R";
}

.uvq04-gear:has(label:nth-of-type(3) input:checked) .kb {
  --g: 2;
  --l: "N";
}

.uvq04-gear:has(label:nth-of-type(4) input:checked) .kb {
  --g: 3;
  --l: "D";
}

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

### React

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

const css = `
.uvq04-gear {
  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;
}

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

.uvq04-gear .pn {
  display: flex;
  gap: .6em;
  padding: 1em 1.3em 1em .9em;
  border-radius: 1.3em;
  color: #e4e6ea;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c2),#fff 12%),color-mix(in srgb,var(--c2),#000 45%));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14),inset 0 -.2em .5em rgba(0,0,0,.4),0 1.4em 2.4em -1.2em rgba(0,0,0,.7);
}

.uvq04-gear .gt {
  position: relative;
  width: .9em;
  margin: .2em .8em;
  border-radius: 1em;
  background: #08090b;
  box-shadow: inset 0 .2em .35em #000,0 1px 0 rgba(255,255,255,.12);
}

.uvq04-gear .kb {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2.3em;
  height: 2.3em;
  margin: -.15em 0 0 -1.15em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%,#8a909b,#363a42 55%,#16181c);
  box-shadow: 0 .5em .9em -.1em rgba(0,0,0,.75),inset 0 1px 1px rgba(255,255,255,.35);
  transform: translateY(calc(var(--g,0) * 2.6em));
  transition: transform calc(0.55s / var(--k)) cubic-bezier(.4,1.5,.5,1);
}

.uvq04-gear .kb::after {
  content: var(--l,"P");
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: .8em;
  font-weight: 800;
  color: var(--c1);
  text-shadow: 0 0 .5em var(--c1);
}

.uvq04-gear .ls {
  display: grid;
  gap: .2em;
}

.uvq04-gear label {
  position: relative;
  display: flex;
  align-items: center;
  gap: .8em;
  height: 2.4em;
  padding: 0 .8em 0 .5em;
  border-radius: .7em;
  cursor: pointer;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

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

.uvq04-gear b {
  width: 1em;
  font-size: 1.55em;
  font-weight: 800;
  text-align: center;
  color: #5b6069;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),text-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-gear label span {
  font-size: .8em;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  color: #868b94;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-gear label:hover {
  background: rgba(255,255,255,.05);
}

.uvq04-gear label:hover b {
  color: #9aa0aa;
}

.uvq04-gear label:active {
  background: rgba(255,255,255,.1);
}

.uvq04-gear input:checked + b {
  color: var(--c1);
  text-shadow: 0 0 .35em var(--c1),0 0 1.2em color-mix(in srgb,var(--c1) 60%,transparent);
}

.uvq04-gear input:checked ~ span {
  color: #f2f3f5;
}

.uvq04-gear label:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq04-gear:has(label:nth-of-type(1) input:checked) .kb {
  --g: 0;
  --l: "P";
}

.uvq04-gear:has(label:nth-of-type(2) input:checked) .kb {
  --g: 1;
  --l: "R";
}

.uvq04-gear:has(label:nth-of-type(3) input:checked) .kb {
  --g: 2;
  --l: "N";
}

.uvq04-gear:has(label:nth-of-type(4) input:checked) .kb {
  --g: 3;
  --l: "D";
}

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

export default function RdGearShift() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#ffa21f",
          "--c2": "#2a2e35",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <fieldset className="uvq04-gear"><legend>Gear</legend><div className="pn"><span className="gt" aria-hidden="true"><i className="kb"></i></span><div className="ls"><label><input type="radio" name="uvq04-gear" checked={true} /><b>P</b><span>Park</span></label><label><input type="radio" name="uvq04-gear" /><b>R</b><span>Reverse</span></label><label><input type="radio" name="uvq04-gear" /><b>N</b><span>Neutral</span></label><label><input type="radio" name="uvq04-gear" /><b>D</b><span>Drive</span></label></div></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 “Automatic gear selector radio” block (Radio buttons) from AIMRAN Library to my project.

## What it is
An automatic gear lever slides along the P, R, N, D gate and the chosen letter lights up in amber.

## Chosen settings
- Main color: #ffa21f
- Secondary color: #2a2e35
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Cambio"

## 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-gear {
  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;
}

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

.uvq04-gear .pn {
  display: flex;
  gap: .6em;
  padding: 1em 1.3em 1em .9em;
  border-radius: 1.3em;
  color: #e4e6ea;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c2),#fff 12%),color-mix(in srgb,var(--c2),#000 45%));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14),inset 0 -.2em .5em rgba(0,0,0,.4),0 1.4em 2.4em -1.2em rgba(0,0,0,.7);
}

.uvq04-gear .gt {
  position: relative;
  width: .9em;
  margin: .2em .8em;
  border-radius: 1em;
  background: #08090b;
  box-shadow: inset 0 .2em .35em #000,0 1px 0 rgba(255,255,255,.12);
}

.uvq04-gear .kb {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2.3em;
  height: 2.3em;
  margin: -.15em 0 0 -1.15em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%,#8a909b,#363a42 55%,#16181c);
  box-shadow: 0 .5em .9em -.1em rgba(0,0,0,.75),inset 0 1px 1px rgba(255,255,255,.35);
  transform: translateY(calc(var(--g,0) * 2.6em));
  transition: transform calc(0.55s / var(--k)) cubic-bezier(.4,1.5,.5,1);
}

.uvq04-gear .kb::after {
  content: var(--l,"P");
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: .8em;
  font-weight: 800;
  color: var(--c1);
  text-shadow: 0 0 .5em var(--c1);
}

.uvq04-gear .ls {
  display: grid;
  gap: .2em;
}

.uvq04-gear label {
  position: relative;
  display: flex;
  align-items: center;
  gap: .8em;
  height: 2.4em;
  padding: 0 .8em 0 .5em;
  border-radius: .7em;
  cursor: pointer;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

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

.uvq04-gear b {
  width: 1em;
  font-size: 1.55em;
  font-weight: 800;
  text-align: center;
  color: #5b6069;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),text-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-gear label span {
  font-size: .8em;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  color: #868b94;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-gear label:hover {
  background: rgba(255,255,255,.05);
}

.uvq04-gear label:hover b {
  color: #9aa0aa;
}

.uvq04-gear label:active {
  background: rgba(255,255,255,.1);
}

.uvq04-gear input:checked + b {
  color: var(--c1);
  text-shadow: 0 0 .35em var(--c1),0 0 1.2em color-mix(in srgb,var(--c1) 60%,transparent);
}

.uvq04-gear input:checked ~ span {
  color: #f2f3f5;
}

.uvq04-gear label:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq04-gear:has(label:nth-of-type(1) input:checked) .kb {
  --g: 0;
  --l: "P";
}

.uvq04-gear:has(label:nth-of-type(2) input:checked) .kb {
  --g: 1;
  --l: "R";
}

.uvq04-gear:has(label:nth-of-type(3) input:checked) .kb {
  --g: 2;
  --l: "N";
}

.uvq04-gear:has(label:nth-of-type(4) input:checked) .kb {
  --g: 3;
  --l: "D";
}

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

export default function RdGearShift() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#ffa21f",
          "--c2": "#2a2e35",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <fieldset className="uvq04-gear"><legend>Gear</legend><div className="pn"><span className="gt" aria-hidden="true"><i className="kb"></i></span><div className="ls"><label><input type="radio" name="uvq04-gear" checked={true} /><b>P</b><span>Park</span></label><label><input type="radio" name="uvq04-gear" /><b>R</b><span>Reverse</span></label><label><input type="radio" name="uvq04-gear" /><b>N</b><span>Neutral</span></label><label><input type="radio" name="uvq04-gear" /><b>D</b><span>Drive</span></label></div></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.
````
