# Glass spirit level

> A builder’s level with a glass vial: tilt it by dragging or with the arrow keys and the bubble springs across.

- Category: [Liquid Glass](https://library.aimran.es/components/liquid-glass)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-lg-spirit-level
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A yellow aluminium spirit level with a realistic glass vial: lime liquid, highlights along the tube, two reference lines and an air bubble with a dark refraction rim. The bubble moves with spring physics towards the high side, and a readout shows the angle with a check when it is level. It suits tools, calibration screens and playful sliders.

Use the vial color for the liquid and the body color for the tool itself. It behaves as an accessible slider from minus twelve to twelve degrees, so keyboards, screen readers and touch drags all work.

## Code

### HTML

```html
<div class="uvq11-lvl"><div class="lv" role="slider" tabindex="0" aria-label="Tilt" aria-valuemin="-12" aria-valuemax="12" aria-valuenow="3" aria-valuetext="3,0°"><i class="cap l"></i><span class="br">60 cm</span><span class="wd"><span class="vi"><i class="mk"></i><i class="bu"></i></span></span><i class="cap r"></i></div><p class="ro"><b>3,0°</b><span class="ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>Level</span></p></div>
```

### CSS

```css
.uvq11-lvl {
  --c1: #b6e94a;
  --c2: #f7c600;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq11-lvl {
  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;
  width: 20em;
  height: 14em;
  border-radius: 1.6em;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
  --a: 0deg;
  --bx: 0em;
  color: #2b1d10;
  background: radial-gradient(70% 60% at 30% 20%,rgba(255,240,210,.55),transparent 70%),repeating-linear-gradient(177deg,#c99566 0 .32em,#b9824f .32em .45em,#d4a373 .45em .95em,#c18b5a .95em 1.2em);
}

.uvq11-lvl .lv {
  position: absolute;
  left: 2em;
  top: 3.6em;
  width: 16em;
  height: 3.2em;
  border-radius: .35em;
  cursor: ew-resize;
  touch-action: none;
  transform: rotate(var(--a));
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.35) 0 1px,transparent 1px .5em) 0 0/100% .45em no-repeat,linear-gradient(180deg,color-mix(in srgb,var(--c2) 55%,#fff) 0,var(--c2) 18%,color-mix(in srgb,var(--c2) 85%,#000) 82%,color-mix(in srgb,var(--c2) 60%,#000));
  box-shadow: 0 .9em 1em -.5em rgba(60,30,0,.55),inset 0 1px 0 rgba(255,255,255,.6);
}

.uvq11-lvl .lv:focus-visible {
  outline: 2px solid #2b1d10;
  outline-offset: 4px;
}

.uvq11-lvl .cap {
  position: absolute;
  top: -.1em;
  bottom: -.1em;
  width: 1.1em;
  border-radius: .3em;
  background: linear-gradient(180deg,#3a3a3a,#111 60%,#2a2a2a);
}

.uvq11-lvl .cap.l {
  left: -.2em;
}

.uvq11-lvl .cap.r {
  right: -.2em;
}

.uvq11-lvl .br {
  position: absolute;
  left: 1.9em;
  bottom: .5em;
  font-size: .55em;
  font-weight: 800;
  letter-spacing: .12em;
  color: rgba(0,0,0,.6);
}

.uvq11-lvl .wd {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7.6em;
  height: 2em;
  margin: -1em 0 0 -3.8em;
  border-radius: .6em;
  background: #1b1b1b;
  box-shadow: inset 0 .15em .3em rgba(0,0,0,.8),0 1px 0 rgba(255,255,255,.4);
}

.uvq11-lvl .vi {
  position: absolute;
  left: .5em;
  right: .5em;
  top: .38em;
  bottom: .38em;
  border-radius: .62em;
  overflow: hidden;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 55%,#fff) 0,var(--c1) 35%,color-mix(in srgb,var(--c1) 65%,#000) 100%);
}

.uvq11-lvl .vi::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg,rgba(255,255,255,.85) 0 7%,rgba(255,255,255,.2) 18%,transparent 38%,transparent 72%,rgba(255,255,255,.35) 86%,transparent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35),inset .4em 0 .5em -.3em rgba(0,0,0,.3),inset -.4em 0 .5em -.3em rgba(0,0,0,.3);
}

.uvq11-lvl .mk::before,.uvq11-lvl .mk::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: .12em;
  background: rgba(0,0,0,.75);
  z-index: 1;
}

.uvq11-lvl .mk::before {
  left: calc(50% - .95em);
}

.uvq11-lvl .mk::after {
  left: calc(50% + .83em);
}

.uvq11-lvl .bu {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.55em;
  height: .78em;
  margin: -.42em 0 0 -.775em;
  border-radius: 50%;
  transform: translateX(var(--bx));
  background: radial-gradient(ellipse at 50% 30%,rgba(255,255,255,.98) 0 20%,color-mix(in srgb,var(--c1) 30%,#fff) 55%,color-mix(in srgb,var(--c1) 60%,#fff));
  box-shadow: 0 0 0 .07em color-mix(in srgb,var(--c1) 45%,#000),inset 0 -.1em .15em rgba(0,0,0,.2);
}

.uvq11-lvl .ro {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.1em;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7em;
}

.uvq11-lvl .ro b {
  box-sizing: border-box;
  width: 4.2em;
  padding: .2em .5em;
  border-radius: .4em;
  text-align: center;
  font-size: 1.5em;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  background: rgba(255,255,255,.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.uvq11-lvl .ok {
  position: absolute;
  left: calc(50% + 3.2em);
  display: inline-flex;
  align-items: center;
  gap: .3em;
  padding: .4em .8em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 700;
  color: #fff;
  background: #1f8a4c;
  opacity: 0;
  transform: scale(.7);
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.35s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq11-lvl .ok svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq11-lvl.ok .ok {
  opacity: 1;
  transform: none;
}

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

### JavaScript

```js
document.querySelectorAll(".uvq11-lvl").forEach(el => {
  const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;const lv=el.querySelector(".lv"),out=el.querySelector(".ro b"),lang=document.documentElement.lang||undefined;let a=0,bx=0,v=0,raf=0,dr=null;
const tgt=()=>Math.max(-2.55,Math.min(2.55,-a*.55));
const fmt=n=>(Math.round(n*10)/10||0).toLocaleString(lang,{minimumFractionDigits:1,maximumFractionDigits:1})+"°";
const step=()=>{const t=tgt();v=(v+(t-bx)*.07)*.84;bx+=v;el.style.setProperty("--bx",bx.toFixed(3)+"em");if(Math.abs(v)>.0004||Math.abs(t-bx)>.002)raf=requestAnimationFrame(step);else raf=0};
const go=()=>{if(rm){bx=tgt();el.style.setProperty("--bx",bx+"em");return}if(!raf)raf=requestAnimationFrame(step)};
const set=n=>{a=Math.max(-12,Math.min(12,n));el.style.setProperty("--a",a.toFixed(2)+"deg");const s=fmt(a);out.textContent=s;lv.setAttribute("aria-valuenow",a.toFixed(1));lv.setAttribute("aria-valuetext",s);el.classList.toggle("ok",Math.abs(a)<.3);go()};
lv.addEventListener("pointerdown",e=>{lv.setPointerCapture(e.pointerId);dr={x:e.clientX,a:a,s:el.getBoundingClientRect().width/el.offsetWidth||1}});
lv.addEventListener("pointermove",e=>{if(dr)set(dr.a+(e.clientX-dr.x)/dr.s*.05)});
const up=()=>{dr=null};lv.addEventListener("pointerup",up);lv.addEventListener("pointercancel",up);
lv.addEventListener("keydown",e=>{const k={ArrowRight:.5,ArrowUp:.5,ArrowLeft:-.5,ArrowDown:-.5,PageUp:2,PageDown:-2}[e.key];if(k!==undefined){e.preventDefault();set(a+k*(e.shiftKey?4:1))}else if(e.key==="Home"){e.preventDefault();set(0)}});
const t0=setTimeout(()=>set(3),300);
return()=>{clearTimeout(t0);cancelAnimationFrame(raf)}
});
```

### 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 = `
.uvq11-lvl {
  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;
  width: 20em;
  height: 14em;
  border-radius: 1.6em;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
  --a: 0deg;
  --bx: 0em;
  color: #2b1d10;
  background: radial-gradient(70% 60% at 30% 20%,rgba(255,240,210,.55),transparent 70%),repeating-linear-gradient(177deg,#c99566 0 .32em,#b9824f .32em .45em,#d4a373 .45em .95em,#c18b5a .95em 1.2em);
}

.uvq11-lvl .lv {
  position: absolute;
  left: 2em;
  top: 3.6em;
  width: 16em;
  height: 3.2em;
  border-radius: .35em;
  cursor: ew-resize;
  touch-action: none;
  transform: rotate(var(--a));
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.35) 0 1px,transparent 1px .5em) 0 0/100% .45em no-repeat,linear-gradient(180deg,color-mix(in srgb,var(--c2) 55%,#fff) 0,var(--c2) 18%,color-mix(in srgb,var(--c2) 85%,#000) 82%,color-mix(in srgb,var(--c2) 60%,#000));
  box-shadow: 0 .9em 1em -.5em rgba(60,30,0,.55),inset 0 1px 0 rgba(255,255,255,.6);
}

.uvq11-lvl .lv:focus-visible {
  outline: 2px solid #2b1d10;
  outline-offset: 4px;
}

.uvq11-lvl .cap {
  position: absolute;
  top: -.1em;
  bottom: -.1em;
  width: 1.1em;
  border-radius: .3em;
  background: linear-gradient(180deg,#3a3a3a,#111 60%,#2a2a2a);
}

.uvq11-lvl .cap.l {
  left: -.2em;
}

.uvq11-lvl .cap.r {
  right: -.2em;
}

.uvq11-lvl .br {
  position: absolute;
  left: 1.9em;
  bottom: .5em;
  font-size: .55em;
  font-weight: 800;
  letter-spacing: .12em;
  color: rgba(0,0,0,.6);
}

.uvq11-lvl .wd {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7.6em;
  height: 2em;
  margin: -1em 0 0 -3.8em;
  border-radius: .6em;
  background: #1b1b1b;
  box-shadow: inset 0 .15em .3em rgba(0,0,0,.8),0 1px 0 rgba(255,255,255,.4);
}

.uvq11-lvl .vi {
  position: absolute;
  left: .5em;
  right: .5em;
  top: .38em;
  bottom: .38em;
  border-radius: .62em;
  overflow: hidden;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 55%,#fff) 0,var(--c1) 35%,color-mix(in srgb,var(--c1) 65%,#000) 100%);
}

.uvq11-lvl .vi::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg,rgba(255,255,255,.85) 0 7%,rgba(255,255,255,.2) 18%,transparent 38%,transparent 72%,rgba(255,255,255,.35) 86%,transparent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35),inset .4em 0 .5em -.3em rgba(0,0,0,.3),inset -.4em 0 .5em -.3em rgba(0,0,0,.3);
}

.uvq11-lvl .mk::before,.uvq11-lvl .mk::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: .12em;
  background: rgba(0,0,0,.75);
  z-index: 1;
}

.uvq11-lvl .mk::before {
  left: calc(50% - .95em);
}

.uvq11-lvl .mk::after {
  left: calc(50% + .83em);
}

.uvq11-lvl .bu {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.55em;
  height: .78em;
  margin: -.42em 0 0 -.775em;
  border-radius: 50%;
  transform: translateX(var(--bx));
  background: radial-gradient(ellipse at 50% 30%,rgba(255,255,255,.98) 0 20%,color-mix(in srgb,var(--c1) 30%,#fff) 55%,color-mix(in srgb,var(--c1) 60%,#fff));
  box-shadow: 0 0 0 .07em color-mix(in srgb,var(--c1) 45%,#000),inset 0 -.1em .15em rgba(0,0,0,.2);
}

.uvq11-lvl .ro {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.1em;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7em;
}

.uvq11-lvl .ro b {
  box-sizing: border-box;
  width: 4.2em;
  padding: .2em .5em;
  border-radius: .4em;
  text-align: center;
  font-size: 1.5em;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  background: rgba(255,255,255,.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.uvq11-lvl .ok {
  position: absolute;
  left: calc(50% + 3.2em);
  display: inline-flex;
  align-items: center;
  gap: .3em;
  padding: .4em .8em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 700;
  color: #fff;
  background: #1f8a4c;
  opacity: 0;
  transform: scale(.7);
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.35s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq11-lvl .ok svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq11-lvl.ok .ok {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion:reduce) {
  .uvq11-lvl,.uvq11-lvl *,.uvq11-lvl *::before,.uvq11-lvl *::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 rm=matchMedia("(prefers-reduced-motion: reduce)").matches;const lv=el.querySelector(".lv"),out=el.querySelector(".ro b"),lang=document.documentElement.lang||undefined;let a=0,bx=0,v=0,raf=0,dr=null;
const tgt=()=>Math.max(-2.55,Math.min(2.55,-a*.55));
const fmt=n=>(Math.round(n*10)/10||0).toLocaleString(lang,{minimumFractionDigits:1,maximumFractionDigits:1})+"°";
const step=()=>{const t=tgt();v=(v+(t-bx)*.07)*.84;bx+=v;el.style.setProperty("--bx",bx.toFixed(3)+"em");if(Math.abs(v)>.0004||Math.abs(t-bx)>.002)raf=requestAnimationFrame(step);else raf=0};
const go=()=>{if(rm){bx=tgt();el.style.setProperty("--bx",bx+"em");return}if(!raf)raf=requestAnimationFrame(step)};
const set=n=>{a=Math.max(-12,Math.min(12,n));el.style.setProperty("--a",a.toFixed(2)+"deg");const s=fmt(a);out.textContent=s;lv.setAttribute("aria-valuenow",a.toFixed(1));lv.setAttribute("aria-valuetext",s);el.classList.toggle("ok",Math.abs(a)<.3);go()};
lv.addEventListener("pointerdown",e=>{lv.setPointerCapture(e.pointerId);dr={x:e.clientX,a:a,s:el.getBoundingClientRect().width/el.offsetWidth||1}});
lv.addEventListener("pointermove",e=>{if(dr)set(dr.a+(e.clientX-dr.x)/dr.s*.05)});
const up=()=>{dr=null};lv.addEventListener("pointerup",up);lv.addEventListener("pointercancel",up);
lv.addEventListener("keydown",e=>{const k={ArrowRight:.5,ArrowUp:.5,ArrowLeft:-.5,ArrowDown:-.5,PageUp:2,PageDown:-2}[e.key];if(k!==undefined){e.preventDefault();set(a+k*(e.shiftKey?4:1))}else if(e.key==="Home"){e.preventDefault();set(0)}});
const t0=setTimeout(()=>set(3),300);
return()=>{clearTimeout(t0);cancelAnimationFrame(raf)}
}

export default function LgSpiritLevel() {
  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": "#b6e94a",
          "--c2": "#f7c600",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq11-lvl"><div className="lv" role="slider" tabIndex={0} aria-label="Tilt" aria-valuemin="-12" aria-valuemax="12" aria-valuenow="3" aria-valuetext="3,0°"><i className="cap l"></i><span className="br">60 cm</span><span className="wd"><span className="vi"><i className="mk"></i><i className="bu"></i></span></span><i className="cap r"></i></div><p className="ro"><b>3,0°</b><span className="ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5" /></svg>Level</span></p></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 “Glass spirit level” block (Liquid Glass) from AIMRAN Library to my project.

## What it is
A builder’s level with a glass vial: tilt it by dragging or with the arrow keys and the bubble springs across.

## Chosen settings
- Main color: #b6e94a
- Secondary color: #f7c600
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "60 cm"

## 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 = `
.uvq11-lvl {
  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;
  width: 20em;
  height: 14em;
  border-radius: 1.6em;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
  --a: 0deg;
  --bx: 0em;
  color: #2b1d10;
  background: radial-gradient(70% 60% at 30% 20%,rgba(255,240,210,.55),transparent 70%),repeating-linear-gradient(177deg,#c99566 0 .32em,#b9824f .32em .45em,#d4a373 .45em .95em,#c18b5a .95em 1.2em);
}

.uvq11-lvl .lv {
  position: absolute;
  left: 2em;
  top: 3.6em;
  width: 16em;
  height: 3.2em;
  border-radius: .35em;
  cursor: ew-resize;
  touch-action: none;
  transform: rotate(var(--a));
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.35) 0 1px,transparent 1px .5em) 0 0/100% .45em no-repeat,linear-gradient(180deg,color-mix(in srgb,var(--c2) 55%,#fff) 0,var(--c2) 18%,color-mix(in srgb,var(--c2) 85%,#000) 82%,color-mix(in srgb,var(--c2) 60%,#000));
  box-shadow: 0 .9em 1em -.5em rgba(60,30,0,.55),inset 0 1px 0 rgba(255,255,255,.6);
}

.uvq11-lvl .lv:focus-visible {
  outline: 2px solid #2b1d10;
  outline-offset: 4px;
}

.uvq11-lvl .cap {
  position: absolute;
  top: -.1em;
  bottom: -.1em;
  width: 1.1em;
  border-radius: .3em;
  background: linear-gradient(180deg,#3a3a3a,#111 60%,#2a2a2a);
}

.uvq11-lvl .cap.l {
  left: -.2em;
}

.uvq11-lvl .cap.r {
  right: -.2em;
}

.uvq11-lvl .br {
  position: absolute;
  left: 1.9em;
  bottom: .5em;
  font-size: .55em;
  font-weight: 800;
  letter-spacing: .12em;
  color: rgba(0,0,0,.6);
}

.uvq11-lvl .wd {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7.6em;
  height: 2em;
  margin: -1em 0 0 -3.8em;
  border-radius: .6em;
  background: #1b1b1b;
  box-shadow: inset 0 .15em .3em rgba(0,0,0,.8),0 1px 0 rgba(255,255,255,.4);
}

.uvq11-lvl .vi {
  position: absolute;
  left: .5em;
  right: .5em;
  top: .38em;
  bottom: .38em;
  border-radius: .62em;
  overflow: hidden;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 55%,#fff) 0,var(--c1) 35%,color-mix(in srgb,var(--c1) 65%,#000) 100%);
}

.uvq11-lvl .vi::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg,rgba(255,255,255,.85) 0 7%,rgba(255,255,255,.2) 18%,transparent 38%,transparent 72%,rgba(255,255,255,.35) 86%,transparent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35),inset .4em 0 .5em -.3em rgba(0,0,0,.3),inset -.4em 0 .5em -.3em rgba(0,0,0,.3);
}

.uvq11-lvl .mk::before,.uvq11-lvl .mk::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: .12em;
  background: rgba(0,0,0,.75);
  z-index: 1;
}

.uvq11-lvl .mk::before {
  left: calc(50% - .95em);
}

.uvq11-lvl .mk::after {
  left: calc(50% + .83em);
}

.uvq11-lvl .bu {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.55em;
  height: .78em;
  margin: -.42em 0 0 -.775em;
  border-radius: 50%;
  transform: translateX(var(--bx));
  background: radial-gradient(ellipse at 50% 30%,rgba(255,255,255,.98) 0 20%,color-mix(in srgb,var(--c1) 30%,#fff) 55%,color-mix(in srgb,var(--c1) 60%,#fff));
  box-shadow: 0 0 0 .07em color-mix(in srgb,var(--c1) 45%,#000),inset 0 -.1em .15em rgba(0,0,0,.2);
}

.uvq11-lvl .ro {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.1em;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7em;
}

.uvq11-lvl .ro b {
  box-sizing: border-box;
  width: 4.2em;
  padding: .2em .5em;
  border-radius: .4em;
  text-align: center;
  font-size: 1.5em;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  background: rgba(255,255,255,.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.uvq11-lvl .ok {
  position: absolute;
  left: calc(50% + 3.2em);
  display: inline-flex;
  align-items: center;
  gap: .3em;
  padding: .4em .8em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 700;
  color: #fff;
  background: #1f8a4c;
  opacity: 0;
  transform: scale(.7);
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.35s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq11-lvl .ok svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq11-lvl.ok .ok {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion:reduce) {
  .uvq11-lvl,.uvq11-lvl *,.uvq11-lvl *::before,.uvq11-lvl *::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 rm=matchMedia("(prefers-reduced-motion: reduce)").matches;const lv=el.querySelector(".lv"),out=el.querySelector(".ro b"),lang=document.documentElement.lang||undefined;let a=0,bx=0,v=0,raf=0,dr=null;
const tgt=()=>Math.max(-2.55,Math.min(2.55,-a*.55));
const fmt=n=>(Math.round(n*10)/10||0).toLocaleString(lang,{minimumFractionDigits:1,maximumFractionDigits:1})+"°";
const step=()=>{const t=tgt();v=(v+(t-bx)*.07)*.84;bx+=v;el.style.setProperty("--bx",bx.toFixed(3)+"em");if(Math.abs(v)>.0004||Math.abs(t-bx)>.002)raf=requestAnimationFrame(step);else raf=0};
const go=()=>{if(rm){bx=tgt();el.style.setProperty("--bx",bx+"em");return}if(!raf)raf=requestAnimationFrame(step)};
const set=n=>{a=Math.max(-12,Math.min(12,n));el.style.setProperty("--a",a.toFixed(2)+"deg");const s=fmt(a);out.textContent=s;lv.setAttribute("aria-valuenow",a.toFixed(1));lv.setAttribute("aria-valuetext",s);el.classList.toggle("ok",Math.abs(a)<.3);go()};
lv.addEventListener("pointerdown",e=>{lv.setPointerCapture(e.pointerId);dr={x:e.clientX,a:a,s:el.getBoundingClientRect().width/el.offsetWidth||1}});
lv.addEventListener("pointermove",e=>{if(dr)set(dr.a+(e.clientX-dr.x)/dr.s*.05)});
const up=()=>{dr=null};lv.addEventListener("pointerup",up);lv.addEventListener("pointercancel",up);
lv.addEventListener("keydown",e=>{const k={ArrowRight:.5,ArrowUp:.5,ArrowLeft:-.5,ArrowDown:-.5,PageUp:2,PageDown:-2}[e.key];if(k!==undefined){e.preventDefault();set(a+k*(e.shiftKey?4:1))}else if(e.key==="Home"){e.preventDefault();set(0)}});
const t0=setTimeout(()=>set(3),300);
return()=>{clearTimeout(t0);cancelAnimationFrame(raf)}
}

export default function LgSpiritLevel() {
  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": "#b6e94a",
          "--c2": "#f7c600",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq11-lvl"><div className="lv" role="slider" tabIndex={0} aria-label="Tilt" aria-valuemin="-12" aria-valuemax="12" aria-valuenow="3" aria-valuetext="3,0°"><i className="cap l"></i><span className="br">60 cm</span><span className="wd"><span className="vi"><i className="mk"></i><i className="bu"></i></span></span><i className="cap r"></i></div><p className="ro"><b>3,0°</b><span className="ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5" /></svg>Level</span></p></div>
      </div>
    </>
  );
}
```

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