# Celsius and Fahrenheit temperature input

> A glass thermometer that rises and shifts from cold to warm with the value; switching units converts the number for you.

- Category: [Inputs](https://library.aimran.es/components/inputs)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-in-thermo-units
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A number input for temperatures with a glass thermometer beside it. The mercury height and its color both come from one CSS variable, mixing the cold and warm colors as the value climbs, and a short label describes how it feels. A segmented control swaps between Celsius and Fahrenheit, converting the value with a quick roll.

Set the warm color as the main color and the cold one as the second. It fits weather widgets, smart home panels, cooking apps and lab forms, and the feeling labels in the script can become ranges for ovens, fridges or aquariums.

## Code

### HTML

```html
<div class="uvq06-tp"><div class="th" aria-hidden="true"><span class="tb"><i class="hg"></i></span><span class="bu"></span></div><div class="sd"><label for="uvq06-tp-in" class="lb">Temperature</label><div class="fd"><input id="uvq06-tp-in" type="number" inputmode="decimal" step="0.5"><span class="un">°C</span></div><div class="sg" role="radiogroup" aria-label="Unit"><label><input type="radio" name="uvq06-tp-u" value="c"><span>°C</span></label><label><input type="radio" name="uvq06-tp-u" value="f"><span>°F</span></label><i aria-hidden="true"></i></div><p class="fl" aria-live="polite"></p></div></div>
```

### CSS

```css
.uvq06-tp {
  --c1: #ef4444;
  --c2: #3b82f6;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq06-tp {
  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;
  display: flex;
  align-items: center;
  gap: 1.4em;
  width: 17em;
  --p: .5;
  --mc: color-mix(in srgb,var(--c1) calc(var(--p) * 100%),var(--c2));
}

.uvq06-tp .th {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 2.4em;
  height: 9.4em;
}

.uvq06-tp .tb {
  position: relative;
  flex: 1;
  width: 1em;
  margin-bottom: -.5em;
  border-radius: 1em 1em 0 0;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 5%,var(--bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),inset .22em 0 .2em -.12em rgba(255,255,255,.5);
}

.uvq06-tp .tb::before {
  content: "";
  position: absolute;
  inset: .6em 0 .8em 60%;
  z-index: 1;
  background: repeating-linear-gradient(0deg,color-mix(in srgb,var(--fg) 30%,transparent) 0 1px,transparent 1px .55em);
}

.uvq06-tp .hg {
  position: absolute;
  left: .24em;
  right: .24em;
  bottom: 0;
  height: calc(var(--p) * 100%);
  border-radius: 1em 1em 0 0;
  background: var(--mc);
  transition: height calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1),background calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .bu {
  position: relative;
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,rgba(255,255,255,.55),transparent 42%),var(--mc);
  box-shadow: 0 0 0 .25em color-mix(in srgb,var(--fg) 5%,var(--bg)),0 0 0 calc(.25em + 1px) color-mix(in srgb,var(--fg) 12%,transparent),0 .5em 1.2em -.2em var(--mc);
  transition: background calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .sd {
  flex: 1;
  min-width: 0;
}

.uvq06-tp .lb {
  display: block;
  margin: 0 0 .45em;
  font-size: .82em;
  font-weight: 650;
}

.uvq06-tp .fd {
  display: flex;
  align-items: baseline;
  gap: .15em;
  padding: .2em .8em;
  border-radius: .9em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
  transition: box-shadow calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .fd:focus-within {
  box-shadow: 0 0 0 2px var(--c1),0 0 0 6px color-mix(in srgb,var(--c1) 18%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
}

.uvq06-tp .fd input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  width: 100%;
  height: 1.6em;
  font-size: 1.9em;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  -moz-appearance: textfield;
  appearance: textfield;
}

.uvq06-tp .fd input::-webkit-inner-spin-button,.uvq06-tp .fd input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.uvq06-tp .fd input.roll {
  animation: uvq06-tp calc(0.45s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq06-tp .un {
  font-size: 1.1em;
  font-weight: 650;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-tp .sg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: .6em;
  padding: .2em;
  border-radius: 2em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-tp .sg label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 1.9em;
  border-radius: 2em;
  font-size: .82em;
  font-weight: 700;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  cursor: pointer;
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .sg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq06-tp .sg label:hover {
  color: var(--fg);
}

.uvq06-tp .sg label:has(input:checked) {
  color: var(--fg);
}

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

.uvq06-tp .sg>i {
  position: absolute;
  top: .2em;
  bottom: .2em;
  left: .2em;
  width: calc(50% - .2em);
  border-radius: 2em;
  background: var(--bg);
  box-shadow: 0 .15em .4em rgba(0,0,0,.18);
  transition: translate calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-tp .sg:has([value="f"]:checked)>i {
  translate: 100% 0;
}

.uvq06-tp .fl {
  min-height: 1.2em;
  margin: .6em 0 0;
  font-size: .8em;
  font-weight: 700;
  color: var(--mc);
}

@keyframes uvq06-tp {
  from {
    transform: translateY(-.6em);
    opacity: 0;
    filter: blur(2px);
  }
}

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

### JavaScript

```js
document.querySelectorAll(".uvq06-tp").forEach(el => {
  const i=el.querySelector(".fd input"),un=el.querySelector(".un"),rs=[...el.querySelectorAll("[type=radio]")],fl=el.querySelector(".fl");let u="c";
const W=[[0,"Below zero"],[10,"Cold"],[18,"Cool"],[25,"Pleasant"],[31,"Warm"],[1e9,"Hot"]];
const cel=()=>{const v=parseFloat(i.value);return isNaN(v)?null:u==="c"?v:(v-32)*5/9};
const draw=()=>{const c=cel();if(c===null){fl.textContent="";return}el.style.setProperty("--p",String(Math.max(0,Math.min(1,(c+20)/65))));fl.textContent=W.find(w=>c<w[0])[1]};
rs.forEach(r=>r.addEventListener("change",()=>{const c=cel();u=r.value;un.textContent=u==="c"?"°C":"°F";if(c!==null){const v=u==="c"?c:c*9/5+32;i.value=String(Math.round(v*2)/2);i.classList.remove("roll");void i.offsetWidth;i.classList.add("roll")}draw()}));
i.addEventListener("input",draw);rs[0].checked=true;i.value="21";draw()
});
```

### 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 = `
.uvq06-tp {
  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;
  display: flex;
  align-items: center;
  gap: 1.4em;
  width: 17em;
  --p: .5;
  --mc: color-mix(in srgb,var(--c1) calc(var(--p) * 100%),var(--c2));
}

.uvq06-tp .th {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 2.4em;
  height: 9.4em;
}

.uvq06-tp .tb {
  position: relative;
  flex: 1;
  width: 1em;
  margin-bottom: -.5em;
  border-radius: 1em 1em 0 0;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 5%,var(--bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),inset .22em 0 .2em -.12em rgba(255,255,255,.5);
}

.uvq06-tp .tb::before {
  content: "";
  position: absolute;
  inset: .6em 0 .8em 60%;
  z-index: 1;
  background: repeating-linear-gradient(0deg,color-mix(in srgb,var(--fg) 30%,transparent) 0 1px,transparent 1px .55em);
}

.uvq06-tp .hg {
  position: absolute;
  left: .24em;
  right: .24em;
  bottom: 0;
  height: calc(var(--p) * 100%);
  border-radius: 1em 1em 0 0;
  background: var(--mc);
  transition: height calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1),background calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .bu {
  position: relative;
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,rgba(255,255,255,.55),transparent 42%),var(--mc);
  box-shadow: 0 0 0 .25em color-mix(in srgb,var(--fg) 5%,var(--bg)),0 0 0 calc(.25em + 1px) color-mix(in srgb,var(--fg) 12%,transparent),0 .5em 1.2em -.2em var(--mc);
  transition: background calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .sd {
  flex: 1;
  min-width: 0;
}

.uvq06-tp .lb {
  display: block;
  margin: 0 0 .45em;
  font-size: .82em;
  font-weight: 650;
}

.uvq06-tp .fd {
  display: flex;
  align-items: baseline;
  gap: .15em;
  padding: .2em .8em;
  border-radius: .9em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
  transition: box-shadow calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .fd:focus-within {
  box-shadow: 0 0 0 2px var(--c1),0 0 0 6px color-mix(in srgb,var(--c1) 18%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
}

.uvq06-tp .fd input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  width: 100%;
  height: 1.6em;
  font-size: 1.9em;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  -moz-appearance: textfield;
  appearance: textfield;
}

.uvq06-tp .fd input::-webkit-inner-spin-button,.uvq06-tp .fd input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.uvq06-tp .fd input.roll {
  animation: uvq06-tp calc(0.45s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq06-tp .un {
  font-size: 1.1em;
  font-weight: 650;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-tp .sg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: .6em;
  padding: .2em;
  border-radius: 2em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-tp .sg label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 1.9em;
  border-radius: 2em;
  font-size: .82em;
  font-weight: 700;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  cursor: pointer;
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .sg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq06-tp .sg label:hover {
  color: var(--fg);
}

.uvq06-tp .sg label:has(input:checked) {
  color: var(--fg);
}

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

.uvq06-tp .sg>i {
  position: absolute;
  top: .2em;
  bottom: .2em;
  left: .2em;
  width: calc(50% - .2em);
  border-radius: 2em;
  background: var(--bg);
  box-shadow: 0 .15em .4em rgba(0,0,0,.18);
  transition: translate calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-tp .sg:has([value="f"]:checked)>i {
  translate: 100% 0;
}

.uvq06-tp .fl {
  min-height: 1.2em;
  margin: .6em 0 0;
  font-size: .8em;
  font-weight: 700;
  color: var(--mc);
}

@keyframes uvq06-tp {
  from {
    transform: translateY(-.6em);
    opacity: 0;
    filter: blur(2px);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-tp,.uvq06-tp *,.uvq06-tp *::before,.uvq06-tp *::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(".fd input"),un=el.querySelector(".un"),rs=[...el.querySelectorAll("[type=radio]")],fl=el.querySelector(".fl");let u="c";
const W=[[0,"Below zero"],[10,"Cold"],[18,"Cool"],[25,"Pleasant"],[31,"Warm"],[1e9,"Hot"]];
const cel=()=>{const v=parseFloat(i.value);return isNaN(v)?null:u==="c"?v:(v-32)*5/9};
const draw=()=>{const c=cel();if(c===null){fl.textContent="";return}el.style.setProperty("--p",String(Math.max(0,Math.min(1,(c+20)/65))));fl.textContent=W.find(w=>c<w[0])[1]};
rs.forEach(r=>r.addEventListener("change",()=>{const c=cel();u=r.value;un.textContent=u==="c"?"°C":"°F";if(c!==null){const v=u==="c"?c:c*9/5+32;i.value=String(Math.round(v*2)/2);i.classList.remove("roll");void i.offsetWidth;i.classList.add("roll")}draw()}));
i.addEventListener("input",draw);rs[0].checked=true;i.value="21";draw()
}

export default function InThermoUnits() {
  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": "#ef4444",
          "--c2": "#3b82f6",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-tp"><div className="th" aria-hidden="true"><span className="tb"><i className="hg"></i></span><span className="bu"></span></div><div className="sd"><label htmlFor="uvq06-tp-in" className="lb">Temperature</label><div className="fd"><input id="uvq06-tp-in" type="number" inputMode="decimal" step="0.5" /><span className="un">°C</span></div><div className="sg" role="radiogroup" aria-label="Unit"><label><input type="radio" name="uvq06-tp-u" value="c" /><span>°C</span></label><label><input type="radio" name="uvq06-tp-u" value="f" /><span>°F</span></label><i aria-hidden="true"></i></div><p className="fl" aria-live="polite"></p></div></div>
      </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 “Celsius and Fahrenheit temperature input” block (Inputs) from AIMRAN Library to my project.

## What it is
A glass thermometer that rises and shifts from cold to warm with the value; switching units converts the number for you.

## Chosen settings
- Main color: #ef4444
- Secondary color: #3b82f6
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Temperatura"

## 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 = `
.uvq06-tp {
  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;
  display: flex;
  align-items: center;
  gap: 1.4em;
  width: 17em;
  --p: .5;
  --mc: color-mix(in srgb,var(--c1) calc(var(--p) * 100%),var(--c2));
}

.uvq06-tp .th {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 2.4em;
  height: 9.4em;
}

.uvq06-tp .tb {
  position: relative;
  flex: 1;
  width: 1em;
  margin-bottom: -.5em;
  border-radius: 1em 1em 0 0;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 5%,var(--bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),inset .22em 0 .2em -.12em rgba(255,255,255,.5);
}

.uvq06-tp .tb::before {
  content: "";
  position: absolute;
  inset: .6em 0 .8em 60%;
  z-index: 1;
  background: repeating-linear-gradient(0deg,color-mix(in srgb,var(--fg) 30%,transparent) 0 1px,transparent 1px .55em);
}

.uvq06-tp .hg {
  position: absolute;
  left: .24em;
  right: .24em;
  bottom: 0;
  height: calc(var(--p) * 100%);
  border-radius: 1em 1em 0 0;
  background: var(--mc);
  transition: height calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1),background calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .bu {
  position: relative;
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,rgba(255,255,255,.55),transparent 42%),var(--mc);
  box-shadow: 0 0 0 .25em color-mix(in srgb,var(--fg) 5%,var(--bg)),0 0 0 calc(.25em + 1px) color-mix(in srgb,var(--fg) 12%,transparent),0 .5em 1.2em -.2em var(--mc);
  transition: background calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .sd {
  flex: 1;
  min-width: 0;
}

.uvq06-tp .lb {
  display: block;
  margin: 0 0 .45em;
  font-size: .82em;
  font-weight: 650;
}

.uvq06-tp .fd {
  display: flex;
  align-items: baseline;
  gap: .15em;
  padding: .2em .8em;
  border-radius: .9em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
  transition: box-shadow calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .fd:focus-within {
  box-shadow: 0 0 0 2px var(--c1),0 0 0 6px color-mix(in srgb,var(--c1) 18%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
}

.uvq06-tp .fd input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  width: 100%;
  height: 1.6em;
  font-size: 1.9em;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  -moz-appearance: textfield;
  appearance: textfield;
}

.uvq06-tp .fd input::-webkit-inner-spin-button,.uvq06-tp .fd input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.uvq06-tp .fd input.roll {
  animation: uvq06-tp calc(0.45s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq06-tp .un {
  font-size: 1.1em;
  font-weight: 650;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-tp .sg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: .6em;
  padding: .2em;
  border-radius: 2em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-tp .sg label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 1.9em;
  border-radius: 2em;
  font-size: .82em;
  font-weight: 700;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  cursor: pointer;
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tp .sg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq06-tp .sg label:hover {
  color: var(--fg);
}

.uvq06-tp .sg label:has(input:checked) {
  color: var(--fg);
}

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

.uvq06-tp .sg>i {
  position: absolute;
  top: .2em;
  bottom: .2em;
  left: .2em;
  width: calc(50% - .2em);
  border-radius: 2em;
  background: var(--bg);
  box-shadow: 0 .15em .4em rgba(0,0,0,.18);
  transition: translate calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-tp .sg:has([value="f"]:checked)>i {
  translate: 100% 0;
}

.uvq06-tp .fl {
  min-height: 1.2em;
  margin: .6em 0 0;
  font-size: .8em;
  font-weight: 700;
  color: var(--mc);
}

@keyframes uvq06-tp {
  from {
    transform: translateY(-.6em);
    opacity: 0;
    filter: blur(2px);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-tp,.uvq06-tp *,.uvq06-tp *::before,.uvq06-tp *::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(".fd input"),un=el.querySelector(".un"),rs=[...el.querySelectorAll("[type=radio]")],fl=el.querySelector(".fl");let u="c";
const W=[[0,"Below zero"],[10,"Cold"],[18,"Cool"],[25,"Pleasant"],[31,"Warm"],[1e9,"Hot"]];
const cel=()=>{const v=parseFloat(i.value);return isNaN(v)?null:u==="c"?v:(v-32)*5/9};
const draw=()=>{const c=cel();if(c===null){fl.textContent="";return}el.style.setProperty("--p",String(Math.max(0,Math.min(1,(c+20)/65))));fl.textContent=W.find(w=>c<w[0])[1]};
rs.forEach(r=>r.addEventListener("change",()=>{const c=cel();u=r.value;un.textContent=u==="c"?"°C":"°F";if(c!==null){const v=u==="c"?c:c*9/5+32;i.value=String(Math.round(v*2)/2);i.classList.remove("roll");void i.offsetWidth;i.classList.add("roll")}draw()}));
i.addEventListener("input",draw);rs[0].checked=true;i.value="21";draw()
}

export default function InThermoUnits() {
  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": "#ef4444",
          "--c2": "#3b82f6",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-tp"><div className="th" aria-hidden="true"><span className="tb"><i className="hg"></i></span><span className="bu"></span></div><div className="sd"><label htmlFor="uvq06-tp-in" className="lb">Temperature</label><div className="fd"><input id="uvq06-tp-in" type="number" inputMode="decimal" step="0.5" /><span className="un">°C</span></div><div className="sg" role="radiogroup" aria-label="Unit"><label><input type="radio" name="uvq06-tp-u" value="c" /><span>°C</span></label><label><input type="radio" name="uvq06-tp-u" value="f" /><span>°F</span></label><i aria-hidden="true"></i></div><p className="fl" aria-live="polite"></p></div></div>
      </div>
    </>
  );
}
```

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