focus-readerv0.5.0

A text, a few words at a time.

<focus-reader> shows a text like subtitles, at a pace you pick, in a panel with its size and progress. It reads the article already on your page, which stays as it is.

npm install focus-reader
pnpm add focus-reader
<script type="module" src="https://cdn.jsdelivr.net/npm/focus-reader/dist/src/register.js"></script>

Read the docsTry it with your text

Lab · 04 · 3 min

The focus reader

A text read a few words at a time, like subtitles, for an article to be read rather than skimmed.

Most of what we read on a screen asks the eye to do two jobs at once: follow the words, and find its way back to the line after every glance away. The focus reader takes the second job off its hands. It shows the text a few words at a time, in the same place, at a pace you choose, and you only have to read.

It has two views. Sequence puts each frame on a band between two rulers, one word or a few at a time. Flow shows the whole text and moves it up a line at a time, the words being read marked, the way an app shows the lyrics of a song.

Reading back matters more than reading fast. Pause, and the sentence shows under the band; the arrows, a scroll or a swipe go a frame back or on. A comma makes a frame stay a beat longer, the end of a sentence two.

It is a single custom element, with no dependency and no framework. Its colours and fonts come from custom properties, its words from a labels attribute, so it fits a page and speaks its language.

The focus reader needs JavaScript.

A live reader: press anywhere in the page to take over.
  • 01

    Two views

    Sequence shows one frame at a time on a band, so the eyes stay still. Flow keeps the whole text in view and moves it up a line at a time, like the lyrics of a song.

  • 02

    It reads your page

    Point it at the article already there. Paragraphs, headings, lists and quotes are read; code, figures and tables are left out. The page stays as it is.

  • 03

    One element

    A single custom element and a few pure functions. No dependency, no framework. Colours and fonts come from custom properties, every word from its labels.

  • 04

    Astro included

    An integration sets the pace, the labels and the theme once for a site; a component wraps an article and adds the button that opens the reader.

Three lines of HTML

Give the reader the id of the text to read and a way to open it. With modal it stays hidden until then; without it, it sits in the page and fills its box. persist remembers each reader's settings in their browser.

On an Astro site, the component wraps the article and adds the button itself. Without JavaScript the article reads as it is, and the button never shows.

Getting started →

HTML

<button onclick="document.querySelector('focus-reader').open()">Focus</button>
<focus-reader for="article-body" heading="A visual direction" modal persist></focus-reader>
<script type="module">import 'focus-reader/element';</script>

Astro

---
import FocusReader from 'focus-reader/astro/FocusReader.astro';
---
<FocusReader heading={title}>
  <article><Content /></article>
</FocusReader>