# Chemical element input with Bohr model

> Type a symbol, a name or an atomic number and its periodic table tile appears, with electrons spinning in their shells.

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

## Where to use it

A search field for chemical elements that answers with a periodic table tile and an inline SVG Bohr model. It accepts symbols, names without accents or atomic numbers, and the arrow keys or the side buttons step through the table. The tile takes the colour of the element family, and each electron shell spins at its own speed and direction.

The main color is the nucleus and the second color the electrons. The demo table covers the first twenty elements plus iron, copper, zinc, silver and gold; add more rows with their shells to the data array. It suits chemistry lessons, quizzes and lab inventory forms.

## Code

### HTML

```html
<div class="uvq06-pe"><label for="uvq06-pe-in" class="lb">Chemical element</label><div class="fd"><button type="button" class="nv" data-s="-1" aria-label="Previous element">‹</button><input id="uvq06-pe-in" autocomplete="off" spellcheck="false" placeholder="Symbol, name or number" aria-describedby="uvq06-pe-h"><button type="button" class="nv" data-s="1" aria-label="Next element">›</button></div><div class="cd" aria-live="polite"><div class="tl"><span class="z"></span><span class="m"></span><b class="sy"></b><span class="nm"></span><span class="ct"></span></div><svg class="bo" viewBox="-64 -64 128 128" aria-hidden="true"></svg></div><p class="ht" id="uvq06-pe-h">Try Fe, oxygen or 11</p></div>
```

### CSS

```css
.uvq06-pe {
  --c1: #6366f1;
  --c2: #0ea5e9;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq06-pe {
  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;
  width: 19em;
  --cc: var(--c1);
}

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

.uvq06-pe .fd {
  display: flex;
  align-items: center;
  gap: .2em;
  padding: .25em;
  border-radius: .9em;
  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-pe .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-pe.bad .fd {
  box-shadow: 0 0 0 2px #e5484d;
  animation: uvq06-pe-x calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-pe input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  width: 0;
  height: 2.2em;
  padding: 0 .4em;
  text-align: center;
}

.uvq06-pe input::placeholder {
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe .nv {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.1em;
  height: 2.1em;
  border-radius: .6em;
  font-size: 1.1em;
  font-weight: 700;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-pe .nv:hover {
  background: color-mix(in srgb,var(--c1) 16%,transparent);
}

.uvq06-pe .nv:active {
  transform: scale(.88);
}

.uvq06-pe .nv:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-pe .cd {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-top: .9em;
}

.uvq06-pe .tl {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  flex: none;
  width: 6.6em;
  padding: .45em .55em .55em;
  border-radius: .6em;
  background: color-mix(in srgb,var(--cc) 16%,var(--bg));
  box-shadow: inset 0 3px 0 var(--cc),0 0 0 1px color-mix(in srgb,var(--cc) 35%,transparent),0 .8em 1.4em -1em rgba(0,0,0,.45);
  transition: background calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-pe .tl.fl {
  animation: uvq06-pe calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-pe .z {
  font-size: .8em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.uvq06-pe .m {
  font-size: .62em;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  align-self: center;
}

.uvq06-pe .sy {
  grid-column: 1/-1;
  margin: .05em 0 0;
  font-size: 2.4em;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.02em;
  color: color-mix(in srgb,var(--cc) 65%,var(--fg));
}

.uvq06-pe .nm {
  grid-column: 1/-1;
  font-size: .82em;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uvq06-pe .ct {
  grid-column: 1/-1;
  margin-top: .15em;
  font-size: .6em;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe .bo {
  flex: 1;
  min-width: 0;
  height: 8.4em;
}

.uvq06-pe .bo .rg {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 18%,transparent);
  stroke-width: .8;
}

.uvq06-pe .bo .hd {
  fill: none;
  stroke: none;
}

.uvq06-pe .bo .nu {
  fill: var(--c1);
}

.uvq06-pe .bo .nz {
  font: 800 7px -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  fill: #fff;
  text-anchor: middle;
}

.uvq06-pe .bo .el {
  fill: var(--c2);
}

.uvq06-pe .bo .sh {
  transform-box: fill-box;
  transform-origin: center;
  animation: uvq06-pe-r calc(var(--d) / var(--k)) linear infinite;
}

.uvq06-pe .bo .sh.rv {
  animation-direction: reverse;
}

.uvq06-pe .bo.fl {
  animation: uvq06-pe-b calc(0.5s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq06-pe .ht {
  min-height: 1.2em;
  margin: .6em 0 0;
  font-size: .74em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe.bad .ht {
  font-weight: 650;
  color: #e5484d;
}

@keyframes uvq06-pe {
  from {
    transform: scale(.85) rotate(-4deg);
    opacity: .4;
  }
}

@keyframes uvq06-pe-b {
  from {
    transform: scale(.7);
    opacity: 0;
  }
}

@keyframes uvq06-pe-r {
  to {
    transform: rotate(360deg);
  }
}

@keyframes uvq06-pe-x {
  25% {
    transform: translateX(-.25em);
  }
  50% {
    transform: translateX(.25em);
  }
  75% {
    transform: translateX(-.1em);
  }
}

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

### JavaScript

```js
document.querySelectorAll(".uvq06-pe").forEach(el => {
  const i=el.querySelector("input"),tl=el.querySelector(".tl"),bo=el.querySelector(".bo"),ht=el.querySelector(".ht"),base=ht.textContent,q=s=>el.querySelector(s);
const E=[["H","Hydrogen",1.008,"nm"],["He","Helium",4.003,"ng"],["Li","Lithium",6.94,"al"],["Be","Beryllium",9.012,"at"],["B","Boron",10.81,"md"],["C","Carbon",12.011,"nm"],["N","Nitrogen",14.007,"nm"],["O","Oxygen",15.999,"nm"],["F","Fluorine",18.998,"ha"],["Ne","Neon",20.18,"ng"],["Na","Sodium",22.99,"al"],["Mg","Magnesium",24.305,"at"],["Al","Aluminium",26.982,"mt"],["Si","Silicon",28.085,"md"],["P","Phosphorus",30.974,"nm"],["S","Sulfur",32.06,"nm"],["Cl","Chlorine",35.45,"ha"],["Ar","Argon",39.95,"ng"],["K","Potassium",39.098,"al"],["Ca","Calcium",40.078,"at"],["Fe","Iron",55.845,"tr",26,[2,8,14,2]],["Cu","Copper",63.546,"tr",29,[2,8,18,1]],["Zn","Zinc",65.38,"tr",30,[2,8,18,2]],["Ag","Silver",107.87,"tr",47,[2,8,18,18,1]],["Au","Gold",196.97,"tr",79,[2,8,18,32,18,1]]];
const K={nm:["Nonmetal","#22c55e"],ng:["Noble gas","#a855f7"],al:["Alkali metal","#ef4444"],at:["Alkaline earth","#f97316"],md:["Metalloid","#14b8a6"],ha:["Halogen","#eab308"],mt:["Metal","#64748b"],tr:["Transition metal","#3b82f6"]};
const norm=s=>s.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim();let cur=0;
const zOf=k=>E[k][4]||k+1;
const shells=k=>{if(E[k][5])return E[k][5];let n=zOf(k);const r=[];for(const c of[2,8,8,2]){if(n<=0)break;r.push(Math.min(c,n));n-=c}return r};
const re=(x,c)=>{x.classList.remove(c);void x.offsetWidth;x.classList.add(c)};
const show=k=>{cur=k;const e=E[k],z=zOf(k),c=K[e[3]];el.style.setProperty("--cc",c[1]);q(".z").textContent=String(z);q(".m").textContent=String(e[2]).replace(".",",");q(".sy").textContent=e[0];q(".nm").textContent=e[1];q(".ct").textContent=c[0];
let s='<circle class="nu" r="8"/><text class="nz" y="2.5">'+z+"</text>";shells(k).forEach((n,j)=>{const r=17+9*j;s+='<circle class="rg" r="'+r+'"/><g class="sh'+(j%2?" rv":"")+'" style="--d:'+(5+j*3)+'s"><circle class="hd" r="'+r+'"/>';for(let p=0;p<n;p++){const a=p/n*6.2832-1.5708;s+='<circle class="el" r="2.2" cx="'+(r*Math.cos(a)).toFixed(2)+'" cy="'+(r*Math.sin(a)).toFixed(2)+'"/>'}s+="</g>"});const V=Math.max(38,17+9*(shells(k).length-1)+5);bo.setAttribute("viewBox",-V+" "+-V+" "+2*V+" "+2*V);bo.innerHTML=s;re(tl,"fl");re(bo,"fl");el.classList.remove("bad");ht.textContent=base};
const find=v=>{const t=norm(v);if(!t)return -1;const n=+t;if(n)return E.findIndex((e,k)=>zOf(k)===n);let k=E.findIndex(e=>e[0].toLowerCase()===t);if(k<0&&t.length>=3)k=E.findIndex(e=>norm(e[1]).startsWith(t));return k};
const go=()=>{const k=find(i.value);if(k>=0){if(k!==cur)show(k)}else if(i.value.trim()){re(el,"bad");ht.textContent="Not in this table: try 1 to 20, Fe, Cu, Zn, Ag or Au"}};
i.addEventListener("input",()=>{const k=find(i.value);if(k>=0&&k!==cur)show(k)});
i.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();go()}else if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault();step(e.key==="ArrowUp"?1:-1)}});
i.addEventListener("change",go);
const step=s=>{const k=(cur+s+E.length)%E.length;show(k);i.value=E[k][0]};
el.querySelectorAll(".nv").forEach(b=>b.addEventListener("click",()=>step(+b.dataset.s)));
i.value="O";show(7)
});
```

### 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-pe {
  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;
  width: 19em;
  --cc: var(--c1);
}

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

.uvq06-pe .fd {
  display: flex;
  align-items: center;
  gap: .2em;
  padding: .25em;
  border-radius: .9em;
  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-pe .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-pe.bad .fd {
  box-shadow: 0 0 0 2px #e5484d;
  animation: uvq06-pe-x calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-pe input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  width: 0;
  height: 2.2em;
  padding: 0 .4em;
  text-align: center;
}

.uvq06-pe input::placeholder {
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe .nv {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.1em;
  height: 2.1em;
  border-radius: .6em;
  font-size: 1.1em;
  font-weight: 700;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-pe .nv:hover {
  background: color-mix(in srgb,var(--c1) 16%,transparent);
}

.uvq06-pe .nv:active {
  transform: scale(.88);
}

.uvq06-pe .nv:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-pe .cd {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-top: .9em;
}

.uvq06-pe .tl {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  flex: none;
  width: 6.6em;
  padding: .45em .55em .55em;
  border-radius: .6em;
  background: color-mix(in srgb,var(--cc) 16%,var(--bg));
  box-shadow: inset 0 3px 0 var(--cc),0 0 0 1px color-mix(in srgb,var(--cc) 35%,transparent),0 .8em 1.4em -1em rgba(0,0,0,.45);
  transition: background calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-pe .tl.fl {
  animation: uvq06-pe calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-pe .z {
  font-size: .8em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.uvq06-pe .m {
  font-size: .62em;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  align-self: center;
}

.uvq06-pe .sy {
  grid-column: 1/-1;
  margin: .05em 0 0;
  font-size: 2.4em;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.02em;
  color: color-mix(in srgb,var(--cc) 65%,var(--fg));
}

.uvq06-pe .nm {
  grid-column: 1/-1;
  font-size: .82em;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uvq06-pe .ct {
  grid-column: 1/-1;
  margin-top: .15em;
  font-size: .6em;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe .bo {
  flex: 1;
  min-width: 0;
  height: 8.4em;
}

.uvq06-pe .bo .rg {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 18%,transparent);
  stroke-width: .8;
}

.uvq06-pe .bo .hd {
  fill: none;
  stroke: none;
}

.uvq06-pe .bo .nu {
  fill: var(--c1);
}

.uvq06-pe .bo .nz {
  font: 800 7px -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  fill: #fff;
  text-anchor: middle;
}

.uvq06-pe .bo .el {
  fill: var(--c2);
}

.uvq06-pe .bo .sh {
  transform-box: fill-box;
  transform-origin: center;
  animation: uvq06-pe-r calc(var(--d) / var(--k)) linear infinite;
}

.uvq06-pe .bo .sh.rv {
  animation-direction: reverse;
}

.uvq06-pe .bo.fl {
  animation: uvq06-pe-b calc(0.5s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq06-pe .ht {
  min-height: 1.2em;
  margin: .6em 0 0;
  font-size: .74em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe.bad .ht {
  font-weight: 650;
  color: #e5484d;
}

@keyframes uvq06-pe {
  from {
    transform: scale(.85) rotate(-4deg);
    opacity: .4;
  }
}

@keyframes uvq06-pe-b {
  from {
    transform: scale(.7);
    opacity: 0;
  }
}

@keyframes uvq06-pe-r {
  to {
    transform: rotate(360deg);
  }
}

@keyframes uvq06-pe-x {
  25% {
    transform: translateX(-.25em);
  }
  50% {
    transform: translateX(.25em);
  }
  75% {
    transform: translateX(-.1em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-pe,.uvq06-pe *,.uvq06-pe *::before,.uvq06-pe *::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"),tl=el.querySelector(".tl"),bo=el.querySelector(".bo"),ht=el.querySelector(".ht"),base=ht.textContent,q=s=>el.querySelector(s);
const E=[["H","Hydrogen",1.008,"nm"],["He","Helium",4.003,"ng"],["Li","Lithium",6.94,"al"],["Be","Beryllium",9.012,"at"],["B","Boron",10.81,"md"],["C","Carbon",12.011,"nm"],["N","Nitrogen",14.007,"nm"],["O","Oxygen",15.999,"nm"],["F","Fluorine",18.998,"ha"],["Ne","Neon",20.18,"ng"],["Na","Sodium",22.99,"al"],["Mg","Magnesium",24.305,"at"],["Al","Aluminium",26.982,"mt"],["Si","Silicon",28.085,"md"],["P","Phosphorus",30.974,"nm"],["S","Sulfur",32.06,"nm"],["Cl","Chlorine",35.45,"ha"],["Ar","Argon",39.95,"ng"],["K","Potassium",39.098,"al"],["Ca","Calcium",40.078,"at"],["Fe","Iron",55.845,"tr",26,[2,8,14,2]],["Cu","Copper",63.546,"tr",29,[2,8,18,1]],["Zn","Zinc",65.38,"tr",30,[2,8,18,2]],["Ag","Silver",107.87,"tr",47,[2,8,18,18,1]],["Au","Gold",196.97,"tr",79,[2,8,18,32,18,1]]];
const K={nm:["Nonmetal","#22c55e"],ng:["Noble gas","#a855f7"],al:["Alkali metal","#ef4444"],at:["Alkaline earth","#f97316"],md:["Metalloid","#14b8a6"],ha:["Halogen","#eab308"],mt:["Metal","#64748b"],tr:["Transition metal","#3b82f6"]};
const norm=s=>s.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim();let cur=0;
const zOf=k=>E[k][4]||k+1;
const shells=k=>{if(E[k][5])return E[k][5];let n=zOf(k);const r=[];for(const c of[2,8,8,2]){if(n<=0)break;r.push(Math.min(c,n));n-=c}return r};
const re=(x,c)=>{x.classList.remove(c);void x.offsetWidth;x.classList.add(c)};
const show=k=>{cur=k;const e=E[k],z=zOf(k),c=K[e[3]];el.style.setProperty("--cc",c[1]);q(".z").textContent=String(z);q(".m").textContent=String(e[2]).replace(".",",");q(".sy").textContent=e[0];q(".nm").textContent=e[1];q(".ct").textContent=c[0];
let s='<circle class="nu" r="8"/><text class="nz" y="2.5">'+z+"</text>";shells(k).forEach((n,j)=>{const r=17+9*j;s+='<circle class="rg" r="'+r+'"/><g class="sh'+(j%2?" rv":"")+'" style="--d:'+(5+j*3)+'s"><circle class="hd" r="'+r+'"/>';for(let p=0;p<n;p++){const a=p/n*6.2832-1.5708;s+='<circle class="el" r="2.2" cx="'+(r*Math.cos(a)).toFixed(2)+'" cy="'+(r*Math.sin(a)).toFixed(2)+'"/>'}s+="</g>"});const V=Math.max(38,17+9*(shells(k).length-1)+5);bo.setAttribute("viewBox",-V+" "+-V+" "+2*V+" "+2*V);bo.innerHTML=s;re(tl,"fl");re(bo,"fl");el.classList.remove("bad");ht.textContent=base};
const find=v=>{const t=norm(v);if(!t)return -1;const n=+t;if(n)return E.findIndex((e,k)=>zOf(k)===n);let k=E.findIndex(e=>e[0].toLowerCase()===t);if(k<0&&t.length>=3)k=E.findIndex(e=>norm(e[1]).startsWith(t));return k};
const go=()=>{const k=find(i.value);if(k>=0){if(k!==cur)show(k)}else if(i.value.trim()){re(el,"bad");ht.textContent="Not in this table: try 1 to 20, Fe, Cu, Zn, Ag or Au"}};
i.addEventListener("input",()=>{const k=find(i.value);if(k>=0&&k!==cur)show(k)});
i.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();go()}else if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault();step(e.key==="ArrowUp"?1:-1)}});
i.addEventListener("change",go);
const step=s=>{const k=(cur+s+E.length)%E.length;show(k);i.value=E[k][0]};
el.querySelectorAll(".nv").forEach(b=>b.addEventListener("click",()=>step(+b.dataset.s)));
i.value="O";show(7)
}

export default function InChemElement() {
  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": "#6366f1",
          "--c2": "#0ea5e9",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-pe"><label htmlFor="uvq06-pe-in" className="lb">Chemical element</label><div className="fd"><button type="button" className="nv" data-s="-1" aria-label="Previous element">‹</button><input id="uvq06-pe-in" autoComplete="off" spellCheck="false" placeholder="Symbol, name or number" aria-describedby="uvq06-pe-h" /><button type="button" className="nv" data-s="1" aria-label="Next element">›</button></div><div className="cd" aria-live="polite"><div className="tl"><span className="z"></span><span className="m"></span><b className="sy"></b><span className="nm"></span><span className="ct"></span></div><svg className="bo" viewBox="-64 -64 128 128" aria-hidden="true"></svg></div><p className="ht" id="uvq06-pe-h">Try Fe, oxygen or 11</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 “Chemical element input with Bohr model” block (Inputs) from AIMRAN Library to my project.

## What it is
Type a symbol, a name or an atomic number and its periodic table tile appears, with electrons spinning in their shells.

## Chosen settings
- Main color: #6366f1
- Secondary color: #0ea5e9
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Elemento químico"

## 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-pe {
  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;
  width: 19em;
  --cc: var(--c1);
}

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

.uvq06-pe .fd {
  display: flex;
  align-items: center;
  gap: .2em;
  padding: .25em;
  border-radius: .9em;
  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-pe .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-pe.bad .fd {
  box-shadow: 0 0 0 2px #e5484d;
  animation: uvq06-pe-x calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-pe input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  width: 0;
  height: 2.2em;
  padding: 0 .4em;
  text-align: center;
}

.uvq06-pe input::placeholder {
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe .nv {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.1em;
  height: 2.1em;
  border-radius: .6em;
  font-size: 1.1em;
  font-weight: 700;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-pe .nv:hover {
  background: color-mix(in srgb,var(--c1) 16%,transparent);
}

.uvq06-pe .nv:active {
  transform: scale(.88);
}

.uvq06-pe .nv:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-pe .cd {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-top: .9em;
}

.uvq06-pe .tl {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  flex: none;
  width: 6.6em;
  padding: .45em .55em .55em;
  border-radius: .6em;
  background: color-mix(in srgb,var(--cc) 16%,var(--bg));
  box-shadow: inset 0 3px 0 var(--cc),0 0 0 1px color-mix(in srgb,var(--cc) 35%,transparent),0 .8em 1.4em -1em rgba(0,0,0,.45);
  transition: background calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-pe .tl.fl {
  animation: uvq06-pe calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-pe .z {
  font-size: .8em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.uvq06-pe .m {
  font-size: .62em;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  align-self: center;
}

.uvq06-pe .sy {
  grid-column: 1/-1;
  margin: .05em 0 0;
  font-size: 2.4em;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.02em;
  color: color-mix(in srgb,var(--cc) 65%,var(--fg));
}

.uvq06-pe .nm {
  grid-column: 1/-1;
  font-size: .82em;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uvq06-pe .ct {
  grid-column: 1/-1;
  margin-top: .15em;
  font-size: .6em;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe .bo {
  flex: 1;
  min-width: 0;
  height: 8.4em;
}

.uvq06-pe .bo .rg {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 18%,transparent);
  stroke-width: .8;
}

.uvq06-pe .bo .hd {
  fill: none;
  stroke: none;
}

.uvq06-pe .bo .nu {
  fill: var(--c1);
}

.uvq06-pe .bo .nz {
  font: 800 7px -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  fill: #fff;
  text-anchor: middle;
}

.uvq06-pe .bo .el {
  fill: var(--c2);
}

.uvq06-pe .bo .sh {
  transform-box: fill-box;
  transform-origin: center;
  animation: uvq06-pe-r calc(var(--d) / var(--k)) linear infinite;
}

.uvq06-pe .bo .sh.rv {
  animation-direction: reverse;
}

.uvq06-pe .bo.fl {
  animation: uvq06-pe-b calc(0.5s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq06-pe .ht {
  min-height: 1.2em;
  margin: .6em 0 0;
  font-size: .74em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-pe.bad .ht {
  font-weight: 650;
  color: #e5484d;
}

@keyframes uvq06-pe {
  from {
    transform: scale(.85) rotate(-4deg);
    opacity: .4;
  }
}

@keyframes uvq06-pe-b {
  from {
    transform: scale(.7);
    opacity: 0;
  }
}

@keyframes uvq06-pe-r {
  to {
    transform: rotate(360deg);
  }
}

@keyframes uvq06-pe-x {
  25% {
    transform: translateX(-.25em);
  }
  50% {
    transform: translateX(.25em);
  }
  75% {
    transform: translateX(-.1em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-pe,.uvq06-pe *,.uvq06-pe *::before,.uvq06-pe *::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"),tl=el.querySelector(".tl"),bo=el.querySelector(".bo"),ht=el.querySelector(".ht"),base=ht.textContent,q=s=>el.querySelector(s);
const E=[["H","Hydrogen",1.008,"nm"],["He","Helium",4.003,"ng"],["Li","Lithium",6.94,"al"],["Be","Beryllium",9.012,"at"],["B","Boron",10.81,"md"],["C","Carbon",12.011,"nm"],["N","Nitrogen",14.007,"nm"],["O","Oxygen",15.999,"nm"],["F","Fluorine",18.998,"ha"],["Ne","Neon",20.18,"ng"],["Na","Sodium",22.99,"al"],["Mg","Magnesium",24.305,"at"],["Al","Aluminium",26.982,"mt"],["Si","Silicon",28.085,"md"],["P","Phosphorus",30.974,"nm"],["S","Sulfur",32.06,"nm"],["Cl","Chlorine",35.45,"ha"],["Ar","Argon",39.95,"ng"],["K","Potassium",39.098,"al"],["Ca","Calcium",40.078,"at"],["Fe","Iron",55.845,"tr",26,[2,8,14,2]],["Cu","Copper",63.546,"tr",29,[2,8,18,1]],["Zn","Zinc",65.38,"tr",30,[2,8,18,2]],["Ag","Silver",107.87,"tr",47,[2,8,18,18,1]],["Au","Gold",196.97,"tr",79,[2,8,18,32,18,1]]];
const K={nm:["Nonmetal","#22c55e"],ng:["Noble gas","#a855f7"],al:["Alkali metal","#ef4444"],at:["Alkaline earth","#f97316"],md:["Metalloid","#14b8a6"],ha:["Halogen","#eab308"],mt:["Metal","#64748b"],tr:["Transition metal","#3b82f6"]};
const norm=s=>s.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim();let cur=0;
const zOf=k=>E[k][4]||k+1;
const shells=k=>{if(E[k][5])return E[k][5];let n=zOf(k);const r=[];for(const c of[2,8,8,2]){if(n<=0)break;r.push(Math.min(c,n));n-=c}return r};
const re=(x,c)=>{x.classList.remove(c);void x.offsetWidth;x.classList.add(c)};
const show=k=>{cur=k;const e=E[k],z=zOf(k),c=K[e[3]];el.style.setProperty("--cc",c[1]);q(".z").textContent=String(z);q(".m").textContent=String(e[2]).replace(".",",");q(".sy").textContent=e[0];q(".nm").textContent=e[1];q(".ct").textContent=c[0];
let s='<circle class="nu" r="8"/><text class="nz" y="2.5">'+z+"</text>";shells(k).forEach((n,j)=>{const r=17+9*j;s+='<circle class="rg" r="'+r+'"/><g class="sh'+(j%2?" rv":"")+'" style="--d:'+(5+j*3)+'s"><circle class="hd" r="'+r+'"/>';for(let p=0;p<n;p++){const a=p/n*6.2832-1.5708;s+='<circle class="el" r="2.2" cx="'+(r*Math.cos(a)).toFixed(2)+'" cy="'+(r*Math.sin(a)).toFixed(2)+'"/>'}s+="</g>"});const V=Math.max(38,17+9*(shells(k).length-1)+5);bo.setAttribute("viewBox",-V+" "+-V+" "+2*V+" "+2*V);bo.innerHTML=s;re(tl,"fl");re(bo,"fl");el.classList.remove("bad");ht.textContent=base};
const find=v=>{const t=norm(v);if(!t)return -1;const n=+t;if(n)return E.findIndex((e,k)=>zOf(k)===n);let k=E.findIndex(e=>e[0].toLowerCase()===t);if(k<0&&t.length>=3)k=E.findIndex(e=>norm(e[1]).startsWith(t));return k};
const go=()=>{const k=find(i.value);if(k>=0){if(k!==cur)show(k)}else if(i.value.trim()){re(el,"bad");ht.textContent="Not in this table: try 1 to 20, Fe, Cu, Zn, Ag or Au"}};
i.addEventListener("input",()=>{const k=find(i.value);if(k>=0&&k!==cur)show(k)});
i.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();go()}else if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault();step(e.key==="ArrowUp"?1:-1)}});
i.addEventListener("change",go);
const step=s=>{const k=(cur+s+E.length)%E.length;show(k);i.value=E[k][0]};
el.querySelectorAll(".nv").forEach(b=>b.addEventListener("click",()=>step(+b.dataset.s)));
i.value="O";show(7)
}

export default function InChemElement() {
  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": "#6366f1",
          "--c2": "#0ea5e9",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-pe"><label htmlFor="uvq06-pe-in" className="lb">Chemical element</label><div className="fd"><button type="button" className="nv" data-s="-1" aria-label="Previous element">‹</button><input id="uvq06-pe-in" autoComplete="off" spellCheck="false" placeholder="Symbol, name or number" aria-describedby="uvq06-pe-h" /><button type="button" className="nv" data-s="1" aria-label="Next element">›</button></div><div className="cd" aria-live="polite"><div className="tl"><span className="z"></span><span className="m"></span><b className="sy"></b><span className="nm"></span><span className="ct"></span></div><svg className="bo" viewBox="-64 -64 128 128" aria-hidden="true"></svg></div><p className="ht" id="uvq06-pe-h">Try Fe, oxygen or 11</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.
````
