A blue old-phone screen full of neon static. Click to tune in, and a message types itself out.
click or tap the screen to tune in
It works the same on phones: tap the screen to tune in, and tap again to go back to static. On narrow screens the phone shrinks to fit. With the keyboard, Tab to the screen and press Enter or Space, and screen readers hear the message once it has typed out. If your device is set to reduce motion, the static stays still and the message appears straight away, without the flicker or typing.
The idea
A hello that has to be found. The screen starts as noise, like an old phone searching for signal, and only says something once you reach out and click.
Words you'll see 14
- component
- A reusable piece of interface, like a component in Figma. TuneIn is one.
- props
- The settings you hand to a component, like message or screen. Change them and the phone changes.
- .tsx (TypeScript)
- The file type here: interface code written in TypeScript, which is JavaScript that also checks what kind of value each setting expects.
- state (useState)
- Something a component remembers, like which moment the screen is in. When it changes, what you see updates.
- useEffect
- Code that runs after something changes, to start timers or drawing. It can clean up after itself, like stopping a timer.
- useRef
- A way to keep hold of a page element without redrawing anything, here the canvas.
- canvas
- A box you can draw on from code, dot by dot or shape by shape.
- requestAnimationFrame
- Asks the browser to run some code just before it next paints the screen. Used for smooth, repeated drawing.
- setTimeout / setInterval
- Run something after a wait (once), or every so often (again and again), in milliseconds.
- @keyframes
- A named animation: what something looks like at the start, the end, and anywhere between.
- SVG path
- A shape written as code: where the pen moves, curves and closes.
- clip-path
- Cuts an element into a shape; anything outside the shape is hidden.
- prefers-reduced-motion
- A device setting for people who find movement uncomfortable. Code can check it and calm things down.
- aria-live
- Tells screen readers to read out text when it changes, like the message once it has typed out.
How it works
Point at a step, tap it or Tab to it, to light up its lines in the code.
- 01
The static
The noise is a tiny drawing surface filled with random dots about 16 times a second, stretched up so every dot is a crisp square.
- The static is drawn on a canvas, a box you can colour dot by dot from code. It's only 260 × 210 dots, stretched to fill the screen with hard edges (image-rendering: pixelated), so each dot becomes a small crisp square.
- Each time it draws, every dot gets the ink colour. About 4 in 10 show, each at a random, faint strength (Math.random), and the rest stay empty.
- It asks the browser for a frame again and again (requestAnimationFrame), but only redraws every 60ms or more, about 16 times a second. That looks like old TV snow rather than a blur.
- Once you tune in, the static fades out and stops redrawing, so it costs nothing while hidden. If your device is set to reduce motion, it stays as one still frame.
TuneIn.tsx// TV static: a tiny canvas refilled with random dots about 16 times a second, stretched up with pixelated edges. function Static({ ink, on }: { ink: string; on: boolean }) { const ref = useRef<HTMLCanvasElement>(null) useEffect(() => { const canvas = ref.current const ctx = canvas?.getContext('2d') if (!canvas || !ctx) return const img = ctx.createImageData(canvas.width, canvas.height) const [r, g, b] = hexToRgb(ink) const still = window.matchMedia('(prefers-reduced-motion: reduce)').matches let frame = 0 let last = -Infinity const draw = (t: number) => { if (t - last > 60) { last = t for (let i = 0; i < img.data.length; i += 4) { img.data[i] = r img.data[i + 1] = g img.data[i + 2] = b img.data[i + 3] = Math.random() < 0.4 ? Math.random() * 120 : 0 // about 4 in 10 dots show, faintly, at random strengths } ctx.putImageData(img, 0, 0) } // only keeps moving while the static is showing, and not for people who asked for less motion if (on && !still) frame = requestAnimationFrame(draw) } frame = requestAnimationFrame(draw) return () => cancelAnimationFrame(frame) }, [ink, on]) return ( <canvas ref={ref} width={260} height={210} aria-hidden="true" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', imageRendering: 'pixelated', opacity: on ? 1 : 0, transition: 'opacity 0.45s ease', }} /> ) }This is part of the file. Copy the complete file from the Code tab.
- 02
Tuning in
One click moves the screen through four moments: static, a quick flicker, typing, done. The next click goes back to static.
- The screen is always in one of four moments, and it remembers which one (useState). It starts on static. Like the variants of one component in Figma.
- Clicking on static starts "tuning": a 0.45-second flicker made of a few jumps in brightness (@keyframes with steps, so it jumps instead of gliding).
- After the flicker, it types one letter every 75ms until the message is complete (setTimeout inside useEffect).
- Any click after tuning in drops it straight back to static, ready to go again.
- If your device is set to reduce motion (prefers-reduced-motion), it skips the flicker and typing and just shows the message.
TuneIn.tsx// four moments: static → tuning (a flicker) → typing → done, and a click goes back to static const [phase, setPhase] = useState<Phase>(defaultTuned ? 'done' : 'static') const [typed, setTyped] = useState(defaultTuned ? message.length : 0) // … useEffect(() => { if (phase === 'tuning') { const t = setTimeout(() => setPhase('typing'), 450) // let the flicker play, then start typing return () => clearTimeout(t) } if (phase === 'typing') { if (typed >= message.length) { setPhase('done') return } const t = setTimeout(() => setTyped((n) => n + 1), typeMs) // one more letter return () => clearTimeout(t) } }, [phase, typed, message.length, typeMs]) function toggle() { if (phase !== 'static') { setPhase('static') // any click after tuning in drops back to static return } const still = window.matchMedia('(prefers-reduced-motion: reduce)').matches setTyped(still ? message.length : 0) setPhase(still ? 'done' : 'tuning') // less motion: skip the flicker and typing, show the message } // … animation: phase === 'tuning' ? 'tuneFlicker 0.45s steps(4)' : 'none',This is part of the file. Copy the complete file from the Code tab.
- 03
The old-phone screen
The bulging outline is what makes it read as an old phone, not a flat rectangle.
- The outline is a shape written in code (SVG path): rounded corners and sides that curve out slightly, like an old LCD screen. M moves the pen, Q draws a curve, Z closes the shape.
- The points are written from 0 to 1 of the screen's width and height, not in pixels, so the same shape stretches to any size.
- The whole screen, static and all, is cut to that outline, like a cookie cutter (clip-path).
You don't need to read the long line of numbers in
SCREEN_PATH. It is the outline, written as points and curves. Drawing your own is easier in a tool like Figma: export the shape as SVG and copy itsdvalue.TuneIn.tsx// The screen outline: rounded corners and sides that bulge out a little, like an old phone LCD. // Units are 0–1 of the screen's width and height, so it stretches to any size. const SCREEN_PATH = 'M0.08,0.03 Q0.5,0 0.92,0.03 Q0.975,0.035 0.975,0.1 Q1,0.5 0.975,0.9 Q0.975,0.965 0.92,0.97 Q0.5,1 0.08,0.97 Q0.025,0.965 0.025,0.9 Q0,0.5 0.025,0.1 Q0.025,0.035 0.08,0.03 Z' // … clipPath: 'url(#tune-in-screen)', // cut the screen to the bulging outlineThis is part of the file. Copy the complete file from the Code tab.
- 04
The live clock
Instead of a frozen 11:11, the corner clock shows your real time.
- The time is filled in after the page has loaded in your browser (useEffect), because the server that builds the page doesn't know your time zone. Until then it shows
--:--. - It reads the hours and minutes (Date), adds a 0 in front of single digits so 9 shows as 09 (padStart), and checks again every 10 seconds (setInterval).
TuneIn.tsx// the real time, filled in after the page loads (the server doesn't know the visitor's time) const [time, setTime] = useState<string | null>(null) useEffect(() => { const update = () => { const d = new Date() setTime(`${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`) } update() const id = setInterval(update, 10_000) return () => clearInterval(id) }, [])This is part of the file. Copy the complete file from the Code tab.
- The time is filled in after the page has loaded in your browser (useEffect), because the server that builds the page doesn't know your time zone. Until then it shows
Use it
Try it here first
Nothing to install. Open the Edit tab, change the code, and watch the preview update as you type.
When you want it in your own project
The buttons above copy the complete files. The code in How it works is only excerpts, so copy from here.
- You need Node.js installed. In a terminal, run
npx create-next-app@latest my-tune-in --yesto make a new Next.js project, thencd my-tune-in. - Inside the
appfolder, make a folder calledcomponents. Copy the complete file with the button above and save it asapp/components/TuneIn.tsx. - Open
app/page.tsx, delete everything in it, and paste the example below. - Run
npm run devand open localhost:3000. Click the screen. - Change these first: the words (
message), the screen colour (screen) and the text and static colour (ink).
import TuneIn from './components/TuneIn'
export default function Page() {
return (
<main style={{ background: '#FFF8E5', minHeight: '100vh', display: 'grid', placeItems: 'center' }}>
<TuneIn
message="hi, you found me" // what types out
screen="#3336A3" // the screen colour
ink="#e4ff5d" // the text and static colour
/>
</main>
)
}What you can change 8
<TuneIn /> 8
messageoptional- The words that type out. Default
hi, you found me. screenoptional- The screen colour, as a 6-digit hex. Default
#3336A3. inkoptional- The text, icons and static colour, as a 6-digit hex. Default
#e4ff5d. widthoptional- How wide the screen is, in pixels. Default
440. heightoptional- How tall the screen is, in pixels. Default
360. typeMsoptional- How long each letter takes to type, in milliseconds. Default
75. defaultTunedoptional- Set to
trueto start on the message instead of static. interactiveoptional- Set to
falsefor a still picture you can't click, like inside a link.
Dependencies 3
- React 18+useState, useEffect and useRef. Nothing else to install.
- No animation libraryThe static is drawn on a small canvas; the flicker and blinking cursor are CSS keyframe animations.
- Pixelify SansOptional pixel font (Pixelify Sans), read from --font-pixelify. Falls back to a monospace font.
Things to learn next 7
- React: State, a component's memory ↗How useState remembers which moment the screen is in.
- React: Synchronizing with Effects ↗How useEffect runs the typing, the static and the clock.
- MDN: Canvas tutorial ↗Drawing from code, from your first rectangle to pixel by pixel.
- MDN: Using CSS animations ↗Writing @keyframes, like the flicker and the blinking cursor.
- MDN: SVG paths ↗What M, Q and Z mean, so you can read and tweak the outline.
- Clippy ↗Draw clip-path shapes visually, then copy the code.
- MDN: prefers-reduced-motion ↗Respecting people who ask for less movement.