# Roll: In the page

> What assistive tech hears, what reduced motion gets, how to style it, how it's drawn on a server, and what it costs.

Source: https://cesarvenzac.com/roll/docs/page

## Read once

Assistive tech hears the value in words, once, and never the drawing that moves, which is hidden from it. The words are the value's text, a node's `aria-label`, `title` or text, or `label` where you give one: give an icon one.

## Reduced motion

Under `prefers-reduced-motion`, nothing moves: the new character fades in where it stands, in less than a fifth of a second, a count goes straight to its number, and a trend still tints. `reducedMotion` says otherwise: `true` to fade whatever the system says, `false` to move.

## Styling

It's text: set its font, size, colour and line height on the element, and they hold while it rolls. Kerning and ligatures are off inside it, so a character is as wide alone as among the others and nothing shifts as it turns into cells and back.

A value that counts draws tabular figures, every digit one width; any other keeps the font's own, whose widths Roll eases as they change. `tabular` says otherwise either way. Tabular figures suit a number that changes while it's watched (a price, a clock, a column of numbers); the font's own, a large figure that changes now and then.

A symbol fades as it leaves its line, and symbols are spaced so that what hangs past a line, a g's tail, an accent, a line set tight, never peeks once a turn lands. A character is one as you read it: an é written as an e and an accent, a flag, a family of emoji.

## On a server

React's `Roll` draws its value as plain text on a server, a number as `format` writes it and an element as React renders it, laid out as the browser will draw it, so nothing moves as the page hydrates. `<roll-text>` takes up the text written inside it before it's defined.

## At rest

At rest the value is one text node, as crisp as any text, selected and copied as text, costing nothing; it goes back to plain text without moving the text after it. Measured in em against a ruler under the same transforms, it rolls true in a scaled sheet or a page zoomed to be filmed.

## Cost

About 9 kB minified and gzipped for `roll`, 10 kB with every entry. Every roller on the page changes in one batch: all write, all read in one layout, all animate, so a table of numbers changing at once lays out once, not once a number. Starting a turn takes about 2 milliseconds for a number, 12 for twenty changing at once and 80 for two hundred, in headless Chromium on one core of a 2.1 GHz server.

Springs play as a CSS `linear()` easing between two keyframes, where the browser has one (Chrome 113, Safari 17.2, Firefox 112), and as a keyframe a frame elsewhere. Any browser with the Web Animations API rolls.

## Roll's docs

- [Overview](https://cesarvenzac.com/roll.md): Text that rolls as it changes: digits turn like an odometer's and keep their places, letters and icons roll over.
- [Getting started](https://cesarvenzac.com/roll/docs/getting-started.md): Install Roll and give it a value to show: in React, in any page, as an element, in Svelte or in Vue.
- [How it rolls](https://cesarvenzac.com/roll/docs/rolling.md): Digits that keep their places and turn the way the number went, everything else rolling over, on springs that carry on.
- [Looks and effects](https://cesarvenzac.com/roll/docs/looks.md): A flat strip, a drum, a cube, a rolling circle, a tipping square or a swap in place, in any direction, faded, scaled or blurred as it goes.
- [Counting and knowing when it's done](https://cesarvenzac.com/roll/docs/numbers.md): Count a number through the values between, tint it as it rises or falls, move several rollers as one, and know when they've landed.
- [In the page](https://cesarvenzac.com/roll/docs/page.md): What assistive tech hears, what reduced motion gets, how to style it, how it's drawn on a server, and what it costs.
- [API reference](https://cesarvenzac.com/roll/docs/api.md): Every function, component and type the package exports, entry by entry: the core, React, the element, Svelte and Vue.
