# Windsock button

> A windsock that fills and flaps as fast as you move the pointer over it, with a wind reading in knots next to it.

- Category: [Buttons](https://library.aimran.es/components/buttons)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-btn-windsock
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A small airfield or beach scene on a sky blue pill: a pole stands in the grass and an orange and white windsock hangs from it. Moving the pointer quickly over the button counts as wind, so the sock lifts, swells and flutters faster, and a chip reads the speed in knots. When the air calms it droops again. Great for kitesurf schools, sailing clubs and weather apps.

The main color is the sock stripes and the secondary color is the sky, so a red and white airport sock works too. A click or keyboard focus sends a gust, and with reduced motion the sock moves without flapping.

## Code

### HTML

```html
<button class="uvq01-wnd" type="button"><span class="po" aria-hidden="true"><span class="sk"><i></i><i></i><i></i><i></i><i></i></span></span><span class="t">See forecast</span><span class="kn" aria-hidden="true"><b>0</b> kn</span></button>
```

### CSS

```css
.uvq01-wnd {
  --c1: #ff6a13;
  --c2: #4aa3df;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq01-wnd {
  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;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  justify-content: flex-start;
  gap: 1em;
  height: 4em;
  padding: 0 .7em 0 5.3em;
  border-radius: 1.1em;
  overflow: hidden;
  color: #0f2a3d;
  font-weight: 750;
  background: radial-gradient(1.4em .6em at 72% 24%,rgba(255,255,255,.85),transparent 70%),radial-gradient(1em .5em at 80% 30%,rgba(255,255,255,.7),transparent 70%),linear-gradient(180deg,color-mix(in srgb,var(--c2) 70%,#fff) 0%,color-mix(in srgb,var(--c2) 25%,#fff) 80%,#7cbf5a 80%,#5aa346 100%);
  box-shadow: inset 0 0 0 1px rgba(15,42,61,.12),0 12px 24px -14px color-mix(in srgb,var(--c2) 70%,#000);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-wnd .po {
  position: absolute;
  left: 1.3em;
  top: .75em;
  bottom: 20%;
  width: .12em;
  border-radius: 1px;
  background: linear-gradient(90deg,#6f7882,#e6e9ec,#848c95);
}

.uvq01-wnd .sk {
  position: absolute;
  left: .05em;
  top: -.5em;
  display: flex;
  width: 2.8em;
  height: 1em;
  transform-origin: 0 50%;
  transform: rotate(var(--a,60deg)) scaleY(var(--sy,.5));
  clip-path: polygon(0 0,100% 22%,100% 78%,0 100%);
}

.uvq01-wnd .sk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,rgba(255,255,255,.35),transparent 45%,rgba(0,0,0,.22));
}

.uvq01-wnd .sk i {
  flex: 1;
  background: var(--c1);
}

.uvq01-wnd .sk i:nth-child(even) {
  background: #fff;
}

.uvq01-wnd .t {
  position: relative;
}

.uvq01-wnd .kn {
  position: relative;
  margin-left: auto;
  padding: .42em .55em;
  border-radius: .5em;
  font: 700 .72em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  white-space: nowrap;
  background: rgba(255,255,255,.7);
}

.uvq01-wnd:active {
  transform: scale(.98);
}

.uvq01-wnd:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}
```

### JavaScript

```js
document.querySelectorAll(".uvq01-wnd").forEach(el => {
  const sk=el.querySelector(".sk"),kb=el.querySelector(".kn b");let w=0,tg=0,lx=0,ly=0,lt=0,raf=0,ph=0,last=0;
const rm=matchMedia("(prefers-reduced-motion: reduce)");
const draw=()=>{const m=rm.matches?0:1;sk.style.setProperty("--a",((1-w)*60+Math.sin(ph)*(1.5+7*w)*m).toFixed(2)+"deg");sk.style.setProperty("--sy",(.5+.5*w+Math.sin(ph*1.7)*.05*w*m).toFixed(3));kb.textContent=String(Math.round(w*28))};
const step=t=>{const dt=Math.min(48,last?t-last:16);last=t;tg*=Math.pow(.965,dt/16);w+=(tg-w)*Math.min(1,.08*dt/16);ph+=dt*(.004+.02*w);draw();if(tg<.005&&w<.005){w=0;tg=0;draw();raf=0;last=0;return}raf=requestAnimationFrame(step)};
const go=()=>{if(!raf){last=0;raf=requestAnimationFrame(step)}};
el.addEventListener("pointermove",e=>{const now=performance.now();if(lt){const v=Math.hypot(e.clientX-lx,e.clientY-ly)/Math.max(8,now-lt);tg=Math.min(1,Math.max(tg,v/1.6))}lx=e.clientX;ly=e.clientY;lt=now;go()});
el.addEventListener("pointerleave",()=>{lt=0});
el.addEventListener("focus",()=>{tg=Math.max(tg,.7);go()});
el.addEventListener("click",()=>{tg=1;go()});
draw();
return()=>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 = `
.uvq01-wnd {
  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;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  justify-content: flex-start;
  gap: 1em;
  height: 4em;
  padding: 0 .7em 0 5.3em;
  border-radius: 1.1em;
  overflow: hidden;
  color: #0f2a3d;
  font-weight: 750;
  background: radial-gradient(1.4em .6em at 72% 24%,rgba(255,255,255,.85),transparent 70%),radial-gradient(1em .5em at 80% 30%,rgba(255,255,255,.7),transparent 70%),linear-gradient(180deg,color-mix(in srgb,var(--c2) 70%,#fff) 0%,color-mix(in srgb,var(--c2) 25%,#fff) 80%,#7cbf5a 80%,#5aa346 100%);
  box-shadow: inset 0 0 0 1px rgba(15,42,61,.12),0 12px 24px -14px color-mix(in srgb,var(--c2) 70%,#000);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-wnd .po {
  position: absolute;
  left: 1.3em;
  top: .75em;
  bottom: 20%;
  width: .12em;
  border-radius: 1px;
  background: linear-gradient(90deg,#6f7882,#e6e9ec,#848c95);
}

.uvq01-wnd .sk {
  position: absolute;
  left: .05em;
  top: -.5em;
  display: flex;
  width: 2.8em;
  height: 1em;
  transform-origin: 0 50%;
  transform: rotate(var(--a,60deg)) scaleY(var(--sy,.5));
  clip-path: polygon(0 0,100% 22%,100% 78%,0 100%);
}

.uvq01-wnd .sk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,rgba(255,255,255,.35),transparent 45%,rgba(0,0,0,.22));
}

.uvq01-wnd .sk i {
  flex: 1;
  background: var(--c1);
}

.uvq01-wnd .sk i:nth-child(even) {
  background: #fff;
}

.uvq01-wnd .t {
  position: relative;
}

.uvq01-wnd .kn {
  position: relative;
  margin-left: auto;
  padding: .42em .55em;
  border-radius: .5em;
  font: 700 .72em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  white-space: nowrap;
  background: rgba(255,255,255,.7);
}

.uvq01-wnd:active {
  transform: scale(.98);
}

.uvq01-wnd:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}
`;

// 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 sk=el.querySelector(".sk"),kb=el.querySelector(".kn b");let w=0,tg=0,lx=0,ly=0,lt=0,raf=0,ph=0,last=0;
const rm=matchMedia("(prefers-reduced-motion: reduce)");
const draw=()=>{const m=rm.matches?0:1;sk.style.setProperty("--a",((1-w)*60+Math.sin(ph)*(1.5+7*w)*m).toFixed(2)+"deg");sk.style.setProperty("--sy",(.5+.5*w+Math.sin(ph*1.7)*.05*w*m).toFixed(3));kb.textContent=String(Math.round(w*28))};
const step=t=>{const dt=Math.min(48,last?t-last:16);last=t;tg*=Math.pow(.965,dt/16);w+=(tg-w)*Math.min(1,.08*dt/16);ph+=dt*(.004+.02*w);draw();if(tg<.005&&w<.005){w=0;tg=0;draw();raf=0;last=0;return}raf=requestAnimationFrame(step)};
const go=()=>{if(!raf){last=0;raf=requestAnimationFrame(step)}};
el.addEventListener("pointermove",e=>{const now=performance.now();if(lt){const v=Math.hypot(e.clientX-lx,e.clientY-ly)/Math.max(8,now-lt);tg=Math.min(1,Math.max(tg,v/1.6))}lx=e.clientX;ly=e.clientY;lt=now;go()});
el.addEventListener("pointerleave",()=>{lt=0});
el.addEventListener("focus",()=>{tg=Math.max(tg,.7);go()});
el.addEventListener("click",()=>{tg=1;go()});
draw();
return()=>cancelAnimationFrame(raf)
}

export default function BtnWindsock() {
  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": "#ff6a13",
          "--c2": "#4aa3df",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uvq01-wnd" type="button"><span className="po" aria-hidden="true"><span className="sk"><i></i><i></i><i></i><i></i><i></i></span></span><span className="t">See forecast</span><span className="kn" aria-hidden="true"><b>0</b> kn</span></button>
      </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 “Windsock button” block (Buttons) from AIMRAN Library to my project.

## What it is
A windsock that fills and flaps as fast as you move the pointer over it, with a wind reading in knots next to it.

## Chosen settings
- Main color: #ff6a13
- Secondary color: #4aa3df
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Ver previsión"

## 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 = `
.uvq01-wnd {
  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;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  justify-content: flex-start;
  gap: 1em;
  height: 4em;
  padding: 0 .7em 0 5.3em;
  border-radius: 1.1em;
  overflow: hidden;
  color: #0f2a3d;
  font-weight: 750;
  background: radial-gradient(1.4em .6em at 72% 24%,rgba(255,255,255,.85),transparent 70%),radial-gradient(1em .5em at 80% 30%,rgba(255,255,255,.7),transparent 70%),linear-gradient(180deg,color-mix(in srgb,var(--c2) 70%,#fff) 0%,color-mix(in srgb,var(--c2) 25%,#fff) 80%,#7cbf5a 80%,#5aa346 100%);
  box-shadow: inset 0 0 0 1px rgba(15,42,61,.12),0 12px 24px -14px color-mix(in srgb,var(--c2) 70%,#000);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-wnd .po {
  position: absolute;
  left: 1.3em;
  top: .75em;
  bottom: 20%;
  width: .12em;
  border-radius: 1px;
  background: linear-gradient(90deg,#6f7882,#e6e9ec,#848c95);
}

.uvq01-wnd .sk {
  position: absolute;
  left: .05em;
  top: -.5em;
  display: flex;
  width: 2.8em;
  height: 1em;
  transform-origin: 0 50%;
  transform: rotate(var(--a,60deg)) scaleY(var(--sy,.5));
  clip-path: polygon(0 0,100% 22%,100% 78%,0 100%);
}

.uvq01-wnd .sk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,rgba(255,255,255,.35),transparent 45%,rgba(0,0,0,.22));
}

.uvq01-wnd .sk i {
  flex: 1;
  background: var(--c1);
}

.uvq01-wnd .sk i:nth-child(even) {
  background: #fff;
}

.uvq01-wnd .t {
  position: relative;
}

.uvq01-wnd .kn {
  position: relative;
  margin-left: auto;
  padding: .42em .55em;
  border-radius: .5em;
  font: 700 .72em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  white-space: nowrap;
  background: rgba(255,255,255,.7);
}

.uvq01-wnd:active {
  transform: scale(.98);
}

.uvq01-wnd:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}
`;

// 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 sk=el.querySelector(".sk"),kb=el.querySelector(".kn b");let w=0,tg=0,lx=0,ly=0,lt=0,raf=0,ph=0,last=0;
const rm=matchMedia("(prefers-reduced-motion: reduce)");
const draw=()=>{const m=rm.matches?0:1;sk.style.setProperty("--a",((1-w)*60+Math.sin(ph)*(1.5+7*w)*m).toFixed(2)+"deg");sk.style.setProperty("--sy",(.5+.5*w+Math.sin(ph*1.7)*.05*w*m).toFixed(3));kb.textContent=String(Math.round(w*28))};
const step=t=>{const dt=Math.min(48,last?t-last:16);last=t;tg*=Math.pow(.965,dt/16);w+=(tg-w)*Math.min(1,.08*dt/16);ph+=dt*(.004+.02*w);draw();if(tg<.005&&w<.005){w=0;tg=0;draw();raf=0;last=0;return}raf=requestAnimationFrame(step)};
const go=()=>{if(!raf){last=0;raf=requestAnimationFrame(step)}};
el.addEventListener("pointermove",e=>{const now=performance.now();if(lt){const v=Math.hypot(e.clientX-lx,e.clientY-ly)/Math.max(8,now-lt);tg=Math.min(1,Math.max(tg,v/1.6))}lx=e.clientX;ly=e.clientY;lt=now;go()});
el.addEventListener("pointerleave",()=>{lt=0});
el.addEventListener("focus",()=>{tg=Math.max(tg,.7);go()});
el.addEventListener("click",()=>{tg=1;go()});
draw();
return()=>cancelAnimationFrame(raf)
}

export default function BtnWindsock() {
  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": "#ff6a13",
          "--c2": "#4aa3df",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uvq01-wnd" type="button"><span className="po" aria-hidden="true"><span className="sk"><i></i><i></i><i></i><i></i><i></i></span></span><span className="t">See forecast</span><span className="kn" aria-hidden="true"><b>0</b> kn</span></button>
      </div>
    </>
  );
}
```

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