Decode
Random glyphs cycle under every letter until each one locks into the real text.
- enhancer
- entrance
- hover
- 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
Decode example
Access granted. Welcome back.
Access granted. Welcome back.
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="decode">Access granted. Welcome back.</p>
import { Decode } from "./motion/react/Decode";
<Decode>Your content</Decode>
<script setup lang="ts">
import Decode from "./motion/vue/Decode.vue";
</script>
<template>
<Decode>Your content</Decode>
</template>
const el = document.querySelector("#title");
el.dataset.motion = "decode";
The wrappers: Decode.tsx (React, TypeScript) and Decode.vue (Vue). Both render the same attributes as the HTML; the loader does the rest.
Options
| Attribute | Default | What it does |
|---|---|---|
data-motion-trigger | both | Plays on |
data-motion-order | start | Letters lock from |
data-motion-duration | 1100 | Time until every letter locks |
data-motion-speed | 40 | Time between glyph changes |
data-motion-glyphs | mixed | Glyph set |
data-motion-color | #f6a04d | Glyph color |
Accessibility
Screen readers hear the real text once (an aria-label on headings, links and buttons, a hidden copy elsewhere) and the moving letters are aria-hidden. Each letter keeps its measured width while it shows a glyph, so nothing around it moves. Text already on screen at load waits for a hover or a replay; reduced motion shows the plain text. The frame loop stops off screen and in hidden tabs.
Size
decode.js is 1.1 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.