# Hi-fi knob toggle

> A knurled aluminium knob turns from 0 to I on a black faceplate, and the arrow keys turn it as well.

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

## Where to use it

Taken from the front panel of a stereo amplifier, this switch is a knurled aluminium knob on a black plate with 0 and I marks and an amber LED. Turning it on rotates the knob a quarter turn with a springy stop, lights the LED and highlights the I. A short script also lets the arrow keys turn it. It suits audio settings and premium hardware sites.

The main color is the LED and the active mark, the second one tints the metal cap. A warm champagne gives a vintage amplifier look, while a cool grey reads as modern studio gear.

## Code

### HTML

```html
<label class="uvq03-hfk"><input type="checkbox" role="switch"><span class="dl"><b class="l0">0</b><b class="l1">I</b><span class="kb"><i></i></span><i class="led"></i></span>Bass boost</label>
```

### CSS

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

.uvq03-hfk {
  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-hfk input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-hfk .dl {
  position: relative;
  display: block;
  flex: none;
  width: 3.7em;
  height: 3.7em;
  border-radius: .6em;
  background: linear-gradient(160deg,#2b2c30,#151619);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1),0 .55em 1em -.5em rgba(0,0,0,.6);
}

.uvq03-hfk .l0,.uvq03-hfk .l1 {
  position: absolute;
  top: .38em;
  font: 700 .6em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #7f828a;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk .l0 {
  left: .75em;
}

.uvq03-hfk .l1 {
  right: .85em;
}

.uvq03-hfk .kb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2.3em;
  height: 2.3em;
  margin: -1.15em 0 0 -1.15em;
  border-radius: 50%;
  background: repeating-conic-gradient(#46484e 0 4deg,#8e9199 4deg 8deg);
  box-shadow: 0 0 0 .1em #0c0c0e,0 .3em .5em rgba(0,0,0,.6);
  transform: rotate(-45deg);
  transition: transform calc(0.5s / var(--k)) cubic-bezier(.34,1.56,.64,1),filter calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk .kb::before {
  content: "";
  position: absolute;
  inset: .15em;
  border-radius: 50%;
  background: radial-gradient(circle,rgba(255,255,255,.35) 0 8%,transparent 9%),conic-gradient(from 20deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2),color-mix(in srgb,var(--c2) 70%,#555),var(--c2),color-mix(in srgb,var(--c2) 85%,#fff),color-mix(in srgb,var(--c2) 70%,#555),color-mix(in srgb,var(--c2) 80%,#fff));
  box-shadow: inset 0 .05em .1em rgba(255,255,255,.7),inset 0 -.08em .15em rgba(0,0,0,.3);
}

.uvq03-hfk .kb i {
  position: absolute;
  left: 50%;
  top: .3em;
  width: .15em;
  height: .6em;
  margin-left: -.075em;
  border-radius: 1em;
  background: #1b1c1f;
}

.uvq03-hfk .led {
  position: absolute;
  left: 50%;
  bottom: .2em;
  width: .24em;
  height: .24em;
  margin-left: -.12em;
  border-radius: 50%;
  background: #3b3d42;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk input:not(:checked) + .dl .l0 {
  color: #eceef2;
}

.uvq03-hfk:hover .kb {
  filter: brightness(1.08);
}

.uvq03-hfk:active .kb {
  scale: .96;
}

.uvq03-hfk input:checked + .dl .kb {
  transform: rotate(45deg);
}

.uvq03-hfk input:checked + .dl .l1 {
  color: var(--c1);
}

.uvq03-hfk input:checked + .dl .led {
  background: var(--c1);
  box-shadow: 0 0 .45em var(--c1);
}

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

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

### JavaScript

```js
document.querySelectorAll(".uvq03-hfk").forEach(el => {
  const i=el.querySelector("input");const k=(e)=>{const on=e.key==="ArrowRight"||e.key==="ArrowUp",off=e.key==="ArrowLeft"||e.key==="ArrowDown";if(!on&&!off)return;e.preventDefault();if(i.checked!==on){i.checked=on;i.dispatchEvent(new Event("change",{bubbles:true}))}};i.addEventListener("keydown",k);return()=>i.removeEventListener("keydown",k)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq03-hfk {
  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-hfk input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-hfk .dl {
  position: relative;
  display: block;
  flex: none;
  width: 3.7em;
  height: 3.7em;
  border-radius: .6em;
  background: linear-gradient(160deg,#2b2c30,#151619);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1),0 .55em 1em -.5em rgba(0,0,0,.6);
}

.uvq03-hfk .l0,.uvq03-hfk .l1 {
  position: absolute;
  top: .38em;
  font: 700 .6em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #7f828a;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk .l0 {
  left: .75em;
}

.uvq03-hfk .l1 {
  right: .85em;
}

.uvq03-hfk .kb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2.3em;
  height: 2.3em;
  margin: -1.15em 0 0 -1.15em;
  border-radius: 50%;
  background: repeating-conic-gradient(#46484e 0 4deg,#8e9199 4deg 8deg);
  box-shadow: 0 0 0 .1em #0c0c0e,0 .3em .5em rgba(0,0,0,.6);
  transform: rotate(-45deg);
  transition: transform calc(0.5s / var(--k)) cubic-bezier(.34,1.56,.64,1),filter calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk .kb::before {
  content: "";
  position: absolute;
  inset: .15em;
  border-radius: 50%;
  background: radial-gradient(circle,rgba(255,255,255,.35) 0 8%,transparent 9%),conic-gradient(from 20deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2),color-mix(in srgb,var(--c2) 70%,#555),var(--c2),color-mix(in srgb,var(--c2) 85%,#fff),color-mix(in srgb,var(--c2) 70%,#555),color-mix(in srgb,var(--c2) 80%,#fff));
  box-shadow: inset 0 .05em .1em rgba(255,255,255,.7),inset 0 -.08em .15em rgba(0,0,0,.3);
}

.uvq03-hfk .kb i {
  position: absolute;
  left: 50%;
  top: .3em;
  width: .15em;
  height: .6em;
  margin-left: -.075em;
  border-radius: 1em;
  background: #1b1c1f;
}

.uvq03-hfk .led {
  position: absolute;
  left: 50%;
  bottom: .2em;
  width: .24em;
  height: .24em;
  margin-left: -.12em;
  border-radius: 50%;
  background: #3b3d42;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk input:not(:checked) + .dl .l0 {
  color: #eceef2;
}

.uvq03-hfk:hover .kb {
  filter: brightness(1.08);
}

.uvq03-hfk:active .kb {
  scale: .96;
}

.uvq03-hfk input:checked + .dl .kb {
  transform: rotate(45deg);
}

.uvq03-hfk input:checked + .dl .l1 {
  color: var(--c1);
}

.uvq03-hfk input:checked + .dl .led {
  background: var(--c1);
  box-shadow: 0 0 .45em var(--c1);
}

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

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

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const i=el.querySelector("input");const k=(e)=>{const on=e.key==="ArrowRight"||e.key==="ArrowUp",off=e.key==="ArrowLeft"||e.key==="ArrowDown";if(!on&&!off)return;e.preventDefault();if(i.checked!==on){i.checked=on;i.dispatchEvent(new Event("change",{bubbles:true}))}};i.addEventListener("keydown",k);return()=>i.removeEventListener("keydown",k)
}

export default function TgHifiKnob() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#ffaa1d",
          "--c2": "#d2d6dc",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-hfk"><input type="checkbox" role="switch" /><span className="dl"><b className="l0">0</b><b className="l1">I</b><span className="kb"><i></i></span><i className="led"></i></span>Bass boost</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 “Hi-fi knob toggle” block (Toggles) from AIMRAN Library to my project.

## What it is
A knurled aluminium knob turns from 0 to I on a black faceplate, and the arrow keys turn it as well.

## Chosen settings
- Main color: #ffaa1d
- Secondary color: #d2d6dc
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Realce de graves"

## 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
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq03-hfk {
  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-hfk input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-hfk .dl {
  position: relative;
  display: block;
  flex: none;
  width: 3.7em;
  height: 3.7em;
  border-radius: .6em;
  background: linear-gradient(160deg,#2b2c30,#151619);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1),0 .55em 1em -.5em rgba(0,0,0,.6);
}

.uvq03-hfk .l0,.uvq03-hfk .l1 {
  position: absolute;
  top: .38em;
  font: 700 .6em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #7f828a;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk .l0 {
  left: .75em;
}

.uvq03-hfk .l1 {
  right: .85em;
}

.uvq03-hfk .kb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2.3em;
  height: 2.3em;
  margin: -1.15em 0 0 -1.15em;
  border-radius: 50%;
  background: repeating-conic-gradient(#46484e 0 4deg,#8e9199 4deg 8deg);
  box-shadow: 0 0 0 .1em #0c0c0e,0 .3em .5em rgba(0,0,0,.6);
  transform: rotate(-45deg);
  transition: transform calc(0.5s / var(--k)) cubic-bezier(.34,1.56,.64,1),filter calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk .kb::before {
  content: "";
  position: absolute;
  inset: .15em;
  border-radius: 50%;
  background: radial-gradient(circle,rgba(255,255,255,.35) 0 8%,transparent 9%),conic-gradient(from 20deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2),color-mix(in srgb,var(--c2) 70%,#555),var(--c2),color-mix(in srgb,var(--c2) 85%,#fff),color-mix(in srgb,var(--c2) 70%,#555),color-mix(in srgb,var(--c2) 80%,#fff));
  box-shadow: inset 0 .05em .1em rgba(255,255,255,.7),inset 0 -.08em .15em rgba(0,0,0,.3);
}

.uvq03-hfk .kb i {
  position: absolute;
  left: 50%;
  top: .3em;
  width: .15em;
  height: .6em;
  margin-left: -.075em;
  border-radius: 1em;
  background: #1b1c1f;
}

.uvq03-hfk .led {
  position: absolute;
  left: 50%;
  bottom: .2em;
  width: .24em;
  height: .24em;
  margin-left: -.12em;
  border-radius: 50%;
  background: #3b3d42;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-hfk input:not(:checked) + .dl .l0 {
  color: #eceef2;
}

.uvq03-hfk:hover .kb {
  filter: brightness(1.08);
}

.uvq03-hfk:active .kb {
  scale: .96;
}

.uvq03-hfk input:checked + .dl .kb {
  transform: rotate(45deg);
}

.uvq03-hfk input:checked + .dl .l1 {
  color: var(--c1);
}

.uvq03-hfk input:checked + .dl .led {
  background: var(--c1);
  box-shadow: 0 0 .45em var(--c1);
}

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

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

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const i=el.querySelector("input");const k=(e)=>{const on=e.key==="ArrowRight"||e.key==="ArrowUp",off=e.key==="ArrowLeft"||e.key==="ArrowDown";if(!on&&!off)return;e.preventDefault();if(i.checked!==on){i.checked=on;i.dispatchEvent(new Event("change",{bubbles:true}))}};i.addEventListener("keydown",k);return()=>i.removeEventListener("keydown",k)
}

export default function TgHifiKnob() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#ffaa1d",
          "--c2": "#d2d6dc",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-hfk"><input type="checkbox" role="switch" /><span className="dl"><b className="l0">0</b><b className="l1">I</b><span className="kb"><i></i></span><i className="led"></i></span>Bass boost</label>
      </div>
    </>
  );
}
```

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