VibeFX
Live preview · fully interactive

The prompt

Build a gooey toggle switch.

## Look
Track 72×40, radius 999px, off #23232e, on #7c6cff. Knob 32px circle #f2f2f7. Page #08080d.

## Behavior
When aria-pressed becomes true, translate the knob 28px on X and scaleX to 1.15. Click toggles the attribute.

## Design tokens
- On #7c6cff; off #23232e; knob #f2f2f7; page #08080d.

## Motion
- Transition 0.35s, easing cubic-bezier(0.16, 1, 0.3, 1).

## Constraints
- Single self-contained HTML file. No libraries.
- Honor prefers-reduced-motion: reduce by skipping the loop and leaving a readable static frame
- Readable at 390px width with no horizontal page scroll

The code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { min-height: 100%; }
  body {
    background: #08080d; color: #f2f2f7; font-family: Inter, system-ui, sans-serif;
    min-height: 100vh; overflow: hidden;
  }
  .hint { position: absolute; left: 16px; top: 16px; z-index: 5; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #8a8a99; }
  main { min-height: 100vh; display: grid; place-items: center; } button { width: 72px; height: 40px; border: 0; border-radius: 999px; background: #23232e; padding: 4px; cursor: pointer; } i { display: block; width: 32px; height: 32px; border-radius: 50%; background: #f2f2f7; transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1); } button[aria-pressed="true"] { background: #7c6cff; } button[aria-pressed="true"] i { transform: translateX(28px) scaleX(1.15); }
  @media (max-width: 420px) {
    .hint { font-size: 10px; letter-spacing: 0.08em; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  }
</style>
</head>
<body>
<main><button id="s" aria-pressed="false" aria-label="Enable motion"><i></i></button></main>

<script>
document.getElementById("s").addEventListener("click", function (e) { var on = e.currentTarget.getAttribute("aria-pressed") === "true"; e.currentTarget.setAttribute("aria-pressed", on ? "false" : "true"); });
</script>
</body>
</html>

About this effect

Clicking the switch translates the knob 28px over 0.35s and briefly scales X to 1.35 so it looks gooey. Aria-pressed tracks the state.

Similar effects