Scramble hover
Letters near the pointer break into random glyphs and settle back as it moves on.
- enhancer
- hover
- pointer
- scramble
- since 0.2
Background Studio: tune it below, then copy the code
Your system asks for reduced motion: the demo shows its final state and nothing moves.
Live demo
Scramble hover example
Run the pointer over this line and the letters scatter.
Run the pointer over this line and the letters scatter.
Code
It follows the controls above: change an option and the code changes with it.
<link rel="stylesheet" href="/axi0/motion/motion.css?v=6">
<script src="/axi0/motion/motion.js?v=10" defer></script>
<p class="demo-big" data-motion="scramble-hover">Run the pointer over this line and the letters scatter.</p>
import { ScrambleHover } from "./motion/react/ScrambleHover";
<ScrambleHover>Your content</ScrambleHover>
<script setup lang="ts">
import ScrambleHover from "./motion/vue/ScrambleHover.vue";
</script>
<template>
<ScrambleHover>Your content</ScrambleHover>
</template>
const el = document.querySelector("#title");
el.dataset.motion = "scramble-hover";
The wrappers: ScrambleHover.tsx (React, TypeScript) and ScrambleHover.vue (Vue). Both render the same attributes as the HTML; the loader does the rest.
Options
| Attribute | Default | What it does |
|---|---|---|
data-motion-radius | 90 | Reach around the pointer |
data-motion-duration | 650 | How long a letter stays scrambled |
data-motion-speed | 45 | Time between glyph changes |
data-motion-glyphs | mixed | Glyph set |
data-motion-color | #f6a04d | Glyph color |
Accessibility
The text never changes for screen readers (one readable copy, the moving letters aria-hidden), and each letter keeps its measured width while scrambled, so nothing shifts. Nothing moves until a pointer does; reduced motion turns the effect off. The frame loop runs only while letters are settling, on screen and in a visible tab.
Size
scramble-hover.js is 1.0 KB gzip, with text-kit.js 2.6 KB it needs. A page loads the loader (2.7 KB) and core.js (1.4 KB) once, whatever it uses.