# Split-flap departure board

> An airport board whose flaps fall one by one to change destination, with the split line and shadow of the real thing.

- Category: [Text & scroll](https://library.aimran.es/components/text-scroll)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-tx-split-flap
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Split-flap boards still define train stations and airports, and this block rebuilds one with CSS 3D: every character is a tile with two halves, and the top flap falls to reveal the next letter. It works for travel brands, event countdowns, launch pages or any headline that should feel mechanical and physical.

Write your own destinations in the list, change the letter color with the main color and the status label with the secondary one. The board pauses while the pointer is over it, and the button announces each change to screen readers.

## Code

### HTML

```html
<div class="uvq14-flap"><div class="bd"><div class="hd"><span>Departures</span><span>Gate B7</span></div><p class="row" aria-hidden="true" translate="no"></p><div class="ft"><span class="st">Boarding</span><span>07:45</span></div></div><p class="sr" aria-live="off">Barcelona</p><ul class="ws" hidden><li>Barcelona</li><li>Lisbon</li><li>Reykjavik</li><li>Marrakech</li><li>Istanbul</li></ul><button type="button" class="nx">Next destination</button></div>
```

### CSS

```css
.uvq14-flap {
  --c1: #f59e0b;
  --c2: #22c55e;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq14-flap {
  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: grid;
  justify-items: center;
  gap: 1em;
}

.uvq14-flap .bd {
  padding: .85em 1em 1em;
  border-radius: .9em;
  background: linear-gradient(#2a2b30,#1b1c1f);
  box-shadow: inset 0 0 0 1px #000,inset 0 1px 0 rgba(255,255,255,.07),0 0 0 1px rgba(255,255,255,.07),0 1.4em 2.4em -1.2em rgba(0,0,0,.55);
}

.uvq14-flap .hd,.uvq14-flap .ft {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #a1a1aa;
}

.uvq14-flap .row {
  display: flex;
  gap: .1em;
  margin: .5em 0 .6em;
  font: 700 1.45em/1 ui-monospace,"SF Mono","JetBrains Mono",Menlo,Consolas,monospace;
  text-transform: uppercase;
}

.uvq14-flap .tl {
  position: relative;
  display: block;
  width: 1.02em;
  height: 1.5em;
  border-radius: .13em;
  background: #111214;
  perspective: 5em;
  box-shadow: 0 .1em .14em rgba(0,0,0,.6);
}

.uvq14-flap .tl::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 4;
  height: 2px;
  margin-top: -1px;
  background: #060607;
}

.uvq14-flap .h {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  height: 50%;
  overflow: hidden;
  color: color-mix(in srgb,var(--c1) 40%,#fff);
  backface-visibility: hidden;
}

.uvq14-flap .u {
  top: 0;
  border-radius: .13em .13em 0 0;
  background: linear-gradient(#26272b,#1e1f22);
  transform-origin: 50% 100%;
}

.uvq14-flap .v {
  bottom: 0;
  border-radius: 0 0 .13em .13em;
  background: linear-gradient(#1b1c1f,#161719);
  transform-origin: 50% 0;
}

.uvq14-flap .h s {
  display: block;
  height: 1.5em;
  line-height: 1.5em;
  text-align: center;
  text-decoration: none;
}

.uvq14-flap .v s {
  margin-top: -.75em;
}

.uvq14-flap .fa,.uvq14-flap .fb {
  z-index: 2;
}

.uvq14-flap .fb {
  transform: rotateX(90deg);
}

.uvq14-flap .go .fa {
  animation: uvq14-flap-a calc(0.14s / var(--k)) ease-in var(--d,0s) both;
}

.uvq14-flap .go .fb {
  animation: uvq14-flap-b calc(0.2s / var(--k)) cubic-bezier(.3,1.6,.6,1) calc(var(--d,0s) + calc(0.14s / var(--k))) both;
}

.uvq14-flap .st {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .3em .6em;
  border-radius: .3em;
  color: #0b0b0c;
  background: var(--c2);
}

.uvq14-flap .st::before {
  content: "";
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #0b0b0c;
  animation: uvq14-flap-blink calc(1.2s / var(--k)) steps(2) infinite;
}

.uvq14-flap .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.uvq14-flap .nx {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .55em 1.1em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 700;
  color: var(--bg);
  background: var(--fg);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq14-flap .nx:hover {
  transform: translateY(-2px);
}

.uvq14-flap .nx:active {
  transform: scale(.95);
}

.uvq14-flap .nx:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq14-flap-a {
  from {
    transform: rotateX(0);
  }
  to {
    transform: rotateX(-90deg);
  }
}

@keyframes uvq14-flap-b {
  from {
    transform: rotateX(90deg);
  }
  to {
    transform: rotateX(0);
  }
}

@keyframes uvq14-flap-blink {
  50% {
    opacity: .2;
  }
}

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

### JavaScript

```js
document.querySelectorAll(".uvq14-flap").forEach(el => {
  const row=el.querySelector(".row"),sr=el.querySelector(".sr"),nx=el.querySelector(".nx");const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;
const words=()=>[...el.querySelectorAll(".ws li")].map(l=>l.textContent.trim());let T=[],i=-1,hold=false,tm=0,iv=0;
const mk=()=>{const n=Math.min(12,Math.max(...words().map(w=>w.length)));if(T.length===n)return;row.textContent="";T=[];for(let j=0;j<n;j++){const t=document.createElement("b");t.className="tl";t.innerHTML='<span class="h u"><s></s></span><span class="h v"><s></s></span><span class="h u fa"><s></s></span><span class="h v fb"><s></s></span>';t.dataset.c=" ";t.addEventListener("animationend",e=>{if(e.target.classList.contains("fb")){t.querySelectorAll("s").forEach(s=>s.textContent=t.dataset.c);t.classList.remove("go")}});row.appendChild(t);T.push(t)}};
const set=(t,c,d)=>{const o=t.dataset.c;if(o===c)return;const s=t.querySelectorAll("s");s[0].textContent=c;s[1].textContent=o;s[2].textContent=o;s[3].textContent=c;t.dataset.c=c;t.classList.remove("go");void t.offsetWidth;t.style.setProperty("--d",(d/k).toFixed(3)+"s");t.classList.add("go")};
const go=(n,live)=>{mk();const w=words();i=(n+w.length)%w.length;const word=w[i].slice(0,T.length).padEnd(T.length," ");sr.setAttribute("aria-live",live?"polite":"off");sr.textContent=w[i];T.forEach((t,j)=>set(t,word[j],j*.05))};
const start=()=>{clearInterval(iv);if(!rm)iv=setInterval(()=>{if(!hold)go(i+1,false)},4800/k)};
mk();{const w=words();i=0;const word=w[0].slice(0,T.length).padEnd(T.length," ");T.forEach((t,j)=>{t.dataset.c=word[j];t.querySelectorAll("s").forEach(s=>s.textContent=word[j])})}tm=setTimeout(()=>go(1,false),1600/k);start();
nx.addEventListener("click",()=>{go(i+1,true);start()});
el.addEventListener("pointerenter",()=>hold=true);el.addEventListener("pointerleave",()=>hold=false);el.addEventListener("focusin",()=>hold=true);el.addEventListener("focusout",()=>hold=false);
return()=>{clearInterval(iv);clearTimeout(tm)}
});
```

### 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 = `
.uvq14-flap {
  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: grid;
  justify-items: center;
  gap: 1em;
}

.uvq14-flap .bd {
  padding: .85em 1em 1em;
  border-radius: .9em;
  background: linear-gradient(#2a2b30,#1b1c1f);
  box-shadow: inset 0 0 0 1px #000,inset 0 1px 0 rgba(255,255,255,.07),0 0 0 1px rgba(255,255,255,.07),0 1.4em 2.4em -1.2em rgba(0,0,0,.55);
}

.uvq14-flap .hd,.uvq14-flap .ft {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #a1a1aa;
}

.uvq14-flap .row {
  display: flex;
  gap: .1em;
  margin: .5em 0 .6em;
  font: 700 1.45em/1 ui-monospace,"SF Mono","JetBrains Mono",Menlo,Consolas,monospace;
  text-transform: uppercase;
}

.uvq14-flap .tl {
  position: relative;
  display: block;
  width: 1.02em;
  height: 1.5em;
  border-radius: .13em;
  background: #111214;
  perspective: 5em;
  box-shadow: 0 .1em .14em rgba(0,0,0,.6);
}

.uvq14-flap .tl::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 4;
  height: 2px;
  margin-top: -1px;
  background: #060607;
}

.uvq14-flap .h {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  height: 50%;
  overflow: hidden;
  color: color-mix(in srgb,var(--c1) 40%,#fff);
  backface-visibility: hidden;
}

.uvq14-flap .u {
  top: 0;
  border-radius: .13em .13em 0 0;
  background: linear-gradient(#26272b,#1e1f22);
  transform-origin: 50% 100%;
}

.uvq14-flap .v {
  bottom: 0;
  border-radius: 0 0 .13em .13em;
  background: linear-gradient(#1b1c1f,#161719);
  transform-origin: 50% 0;
}

.uvq14-flap .h s {
  display: block;
  height: 1.5em;
  line-height: 1.5em;
  text-align: center;
  text-decoration: none;
}

.uvq14-flap .v s {
  margin-top: -.75em;
}

.uvq14-flap .fa,.uvq14-flap .fb {
  z-index: 2;
}

.uvq14-flap .fb {
  transform: rotateX(90deg);
}

.uvq14-flap .go .fa {
  animation: uvq14-flap-a calc(0.14s / var(--k)) ease-in var(--d,0s) both;
}

.uvq14-flap .go .fb {
  animation: uvq14-flap-b calc(0.2s / var(--k)) cubic-bezier(.3,1.6,.6,1) calc(var(--d,0s) + calc(0.14s / var(--k))) both;
}

.uvq14-flap .st {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .3em .6em;
  border-radius: .3em;
  color: #0b0b0c;
  background: var(--c2);
}

.uvq14-flap .st::before {
  content: "";
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #0b0b0c;
  animation: uvq14-flap-blink calc(1.2s / var(--k)) steps(2) infinite;
}

.uvq14-flap .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.uvq14-flap .nx {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .55em 1.1em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 700;
  color: var(--bg);
  background: var(--fg);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq14-flap .nx:hover {
  transform: translateY(-2px);
}

.uvq14-flap .nx:active {
  transform: scale(.95);
}

.uvq14-flap .nx:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq14-flap-a {
  from {
    transform: rotateX(0);
  }
  to {
    transform: rotateX(-90deg);
  }
}

@keyframes uvq14-flap-b {
  from {
    transform: rotateX(90deg);
  }
  to {
    transform: rotateX(0);
  }
}

@keyframes uvq14-flap-blink {
  50% {
    opacity: .2;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq14-flap,.uvq14-flap *,.uvq14-flap *::before,.uvq14-flap *::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 row=el.querySelector(".row"),sr=el.querySelector(".sr"),nx=el.querySelector(".nx");const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;
const words=()=>[...el.querySelectorAll(".ws li")].map(l=>l.textContent.trim());let T=[],i=-1,hold=false,tm=0,iv=0;
const mk=()=>{const n=Math.min(12,Math.max(...words().map(w=>w.length)));if(T.length===n)return;row.textContent="";T=[];for(let j=0;j<n;j++){const t=document.createElement("b");t.className="tl";t.innerHTML='<span class="h u"><s></s></span><span class="h v"><s></s></span><span class="h u fa"><s></s></span><span class="h v fb"><s></s></span>';t.dataset.c=" ";t.addEventListener("animationend",e=>{if(e.target.classList.contains("fb")){t.querySelectorAll("s").forEach(s=>s.textContent=t.dataset.c);t.classList.remove("go")}});row.appendChild(t);T.push(t)}};
const set=(t,c,d)=>{const o=t.dataset.c;if(o===c)return;const s=t.querySelectorAll("s");s[0].textContent=c;s[1].textContent=o;s[2].textContent=o;s[3].textContent=c;t.dataset.c=c;t.classList.remove("go");void t.offsetWidth;t.style.setProperty("--d",(d/k).toFixed(3)+"s");t.classList.add("go")};
const go=(n,live)=>{mk();const w=words();i=(n+w.length)%w.length;const word=w[i].slice(0,T.length).padEnd(T.length," ");sr.setAttribute("aria-live",live?"polite":"off");sr.textContent=w[i];T.forEach((t,j)=>set(t,word[j],j*.05))};
const start=()=>{clearInterval(iv);if(!rm)iv=setInterval(()=>{if(!hold)go(i+1,false)},4800/k)};
mk();{const w=words();i=0;const word=w[0].slice(0,T.length).padEnd(T.length," ");T.forEach((t,j)=>{t.dataset.c=word[j];t.querySelectorAll("s").forEach(s=>s.textContent=word[j])})}tm=setTimeout(()=>go(1,false),1600/k);start();
nx.addEventListener("click",()=>{go(i+1,true);start()});
el.addEventListener("pointerenter",()=>hold=true);el.addEventListener("pointerleave",()=>hold=false);el.addEventListener("focusin",()=>hold=true);el.addEventListener("focusout",()=>hold=false);
return()=>{clearInterval(iv);clearTimeout(tm)}
}

export default function TxSplitFlap() {
  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": "#f59e0b",
          "--c2": "#22c55e",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq14-flap"><div className="bd"><div className="hd"><span>Departures</span><span>Gate B7</span></div><p className="row" aria-hidden="true" translate="no"></p><div className="ft"><span className="st">Boarding</span><span>07:45</span></div></div><p className="sr" aria-live="off">Barcelona</p><ul className="ws" hidden={true}><li>Barcelona</li><li>Lisbon</li><li>Reykjavik</li><li>Marrakech</li><li>Istanbul</li></ul><button type="button" className="nx">Next destination</button></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 “Split-flap departure board” block (Text & scroll) from AIMRAN Library to my project.

## What it is
An airport board whose flaps fall one by one to change destination, with the split line and shadow of the real thing.

## Chosen settings
- Main color: #f59e0b
- Secondary color: #22c55e
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Barcelona"

## 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 = `
.uvq14-flap {
  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: grid;
  justify-items: center;
  gap: 1em;
}

.uvq14-flap .bd {
  padding: .85em 1em 1em;
  border-radius: .9em;
  background: linear-gradient(#2a2b30,#1b1c1f);
  box-shadow: inset 0 0 0 1px #000,inset 0 1px 0 rgba(255,255,255,.07),0 0 0 1px rgba(255,255,255,.07),0 1.4em 2.4em -1.2em rgba(0,0,0,.55);
}

.uvq14-flap .hd,.uvq14-flap .ft {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #a1a1aa;
}

.uvq14-flap .row {
  display: flex;
  gap: .1em;
  margin: .5em 0 .6em;
  font: 700 1.45em/1 ui-monospace,"SF Mono","JetBrains Mono",Menlo,Consolas,monospace;
  text-transform: uppercase;
}

.uvq14-flap .tl {
  position: relative;
  display: block;
  width: 1.02em;
  height: 1.5em;
  border-radius: .13em;
  background: #111214;
  perspective: 5em;
  box-shadow: 0 .1em .14em rgba(0,0,0,.6);
}

.uvq14-flap .tl::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 4;
  height: 2px;
  margin-top: -1px;
  background: #060607;
}

.uvq14-flap .h {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  height: 50%;
  overflow: hidden;
  color: color-mix(in srgb,var(--c1) 40%,#fff);
  backface-visibility: hidden;
}

.uvq14-flap .u {
  top: 0;
  border-radius: .13em .13em 0 0;
  background: linear-gradient(#26272b,#1e1f22);
  transform-origin: 50% 100%;
}

.uvq14-flap .v {
  bottom: 0;
  border-radius: 0 0 .13em .13em;
  background: linear-gradient(#1b1c1f,#161719);
  transform-origin: 50% 0;
}

.uvq14-flap .h s {
  display: block;
  height: 1.5em;
  line-height: 1.5em;
  text-align: center;
  text-decoration: none;
}

.uvq14-flap .v s {
  margin-top: -.75em;
}

.uvq14-flap .fa,.uvq14-flap .fb {
  z-index: 2;
}

.uvq14-flap .fb {
  transform: rotateX(90deg);
}

.uvq14-flap .go .fa {
  animation: uvq14-flap-a calc(0.14s / var(--k)) ease-in var(--d,0s) both;
}

.uvq14-flap .go .fb {
  animation: uvq14-flap-b calc(0.2s / var(--k)) cubic-bezier(.3,1.6,.6,1) calc(var(--d,0s) + calc(0.14s / var(--k))) both;
}

.uvq14-flap .st {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .3em .6em;
  border-radius: .3em;
  color: #0b0b0c;
  background: var(--c2);
}

.uvq14-flap .st::before {
  content: "";
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #0b0b0c;
  animation: uvq14-flap-blink calc(1.2s / var(--k)) steps(2) infinite;
}

.uvq14-flap .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.uvq14-flap .nx {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .55em 1.1em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 700;
  color: var(--bg);
  background: var(--fg);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq14-flap .nx:hover {
  transform: translateY(-2px);
}

.uvq14-flap .nx:active {
  transform: scale(.95);
}

.uvq14-flap .nx:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq14-flap-a {
  from {
    transform: rotateX(0);
  }
  to {
    transform: rotateX(-90deg);
  }
}

@keyframes uvq14-flap-b {
  from {
    transform: rotateX(90deg);
  }
  to {
    transform: rotateX(0);
  }
}

@keyframes uvq14-flap-blink {
  50% {
    opacity: .2;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq14-flap,.uvq14-flap *,.uvq14-flap *::before,.uvq14-flap *::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 row=el.querySelector(".row"),sr=el.querySelector(".sr"),nx=el.querySelector(".nx");const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;
const words=()=>[...el.querySelectorAll(".ws li")].map(l=>l.textContent.trim());let T=[],i=-1,hold=false,tm=0,iv=0;
const mk=()=>{const n=Math.min(12,Math.max(...words().map(w=>w.length)));if(T.length===n)return;row.textContent="";T=[];for(let j=0;j<n;j++){const t=document.createElement("b");t.className="tl";t.innerHTML='<span class="h u"><s></s></span><span class="h v"><s></s></span><span class="h u fa"><s></s></span><span class="h v fb"><s></s></span>';t.dataset.c=" ";t.addEventListener("animationend",e=>{if(e.target.classList.contains("fb")){t.querySelectorAll("s").forEach(s=>s.textContent=t.dataset.c);t.classList.remove("go")}});row.appendChild(t);T.push(t)}};
const set=(t,c,d)=>{const o=t.dataset.c;if(o===c)return;const s=t.querySelectorAll("s");s[0].textContent=c;s[1].textContent=o;s[2].textContent=o;s[3].textContent=c;t.dataset.c=c;t.classList.remove("go");void t.offsetWidth;t.style.setProperty("--d",(d/k).toFixed(3)+"s");t.classList.add("go")};
const go=(n,live)=>{mk();const w=words();i=(n+w.length)%w.length;const word=w[i].slice(0,T.length).padEnd(T.length," ");sr.setAttribute("aria-live",live?"polite":"off");sr.textContent=w[i];T.forEach((t,j)=>set(t,word[j],j*.05))};
const start=()=>{clearInterval(iv);if(!rm)iv=setInterval(()=>{if(!hold)go(i+1,false)},4800/k)};
mk();{const w=words();i=0;const word=w[0].slice(0,T.length).padEnd(T.length," ");T.forEach((t,j)=>{t.dataset.c=word[j];t.querySelectorAll("s").forEach(s=>s.textContent=word[j])})}tm=setTimeout(()=>go(1,false),1600/k);start();
nx.addEventListener("click",()=>{go(i+1,true);start()});
el.addEventListener("pointerenter",()=>hold=true);el.addEventListener("pointerleave",()=>hold=false);el.addEventListener("focusin",()=>hold=true);el.addEventListener("focusout",()=>hold=false);
return()=>{clearInterval(iv);clearTimeout(tm)}
}

export default function TxSplitFlap() {
  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": "#f59e0b",
          "--c2": "#22c55e",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq14-flap"><div className="bd"><div className="hd"><span>Departures</span><span>Gate B7</span></div><p className="row" aria-hidden="true" translate="no"></p><div className="ft"><span className="st">Boarding</span><span>07:45</span></div></div><p className="sr" aria-live="off">Barcelona</p><ul className="ws" hidden={true}><li>Barcelona</li><li>Lisbon</li><li>Reykjavik</li><li>Marrakech</li><li>Istanbul</li></ul><button type="button" className="nx">Next destination</button></div>
      </div>
    </>
  );
}
```

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