Every day, hundreds of millions of people highlight text. They do it to copy a quote, to keep their place, to think. And every time, the browser answers with the same flat rectangle it has drawn since 1995. HyperSelect replaces that rectangle with something alive.
Select any text on this page to see the current preset, then pick another from the bar at the bottom or use the arrow keys. Each preset is a small GLSL shader, many with particles, drawn behind the text while the selection itself stays the browser's own.
Install
pnpm add hyperselect @hyperselect/presets
hyperselect is the engine. The effects live in @hyperselect/presets, released on their own schedule, or you can write your own.
Usage
import { createHyperSelect } from "hyperselect";
import { fire, volt } from "@hyperselect/presets";
const selection = createHyperSelect({ preset: volt });
selection.setPreset(fire);
selection.setTheme("light");
selection.destroy();
| Option | Default | Description |
|---|---|---|
preset |
required | The effect to draw. |
theme |
system preference | 'dark' or 'light', to match your page. Left out, it follows the system as it changes. Containers with their own background follow their own colors. |
root |
document.documentElement |
Only selections inside this element get the effect. |
zIndex |
-1 |
Stacking order of the effect layer. |
padding |
0 |
Extra space around each selected line, in pixels: one number for every side, or { top, right, bottom, left } with any side left out at 0. |
adaptive |
false |
Lowers the render resolution while frames are slow and restores it once they recover. |
Import only the presets you use; the rest are tree-shaken. The engine with one preset weighs about 14 kB gzipped.
Frameworks
Create one instance when your app mounts and destroy it when it unmounts. Importing and calling it during server rendering is safe; it does nothing there.
useEffect(() => {
const selection = createHyperSelect({ preset: volt });
return () => selection.destroy();
}, []);
Keep the instance in a ref to call setPreset or setTheme later instead of recreating it.
One feature, done properly
HyperSelect does one thing. There is no settings panel and no account. The entire product is the moment between your cursor landing on a word and something beautiful happening underneath it, so all of the attention went there.
Effects run on the GPU in a transparent WebGL layer behind your content. Each selected line gets a shader-drawn surface and a population of instanced sprites. The layer lives in document space, so when you scroll, the lightning scrolls with the paragraph it belongs to.
Principles
- Never fight the browser. The selection stays native. HyperSelect reads its geometry and draws behind it; nothing is wrapped, cloned or re-rendered.
- Respond instantly, finish gracefully. Effects begin the moment a line appears, and nothing is cut off when you click away.
- Idle costs nothing. With nothing selected and nothing animating, no frames are drawn at all.
- Respect the reader. With reduced motion enabled, surfaces appear without particles or movement.