# E-ink reader page

> A novel page on an e-ink screen: turning the page triggers the typical negative flash and moves the progress bar.

- Category: [Cards](https://library.aimran.es/components/cards)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-card-eink-reader
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

E-readers have a recognizable quirk: the screen flashes to negative for a moment when the page changes. This card copies it with a stepped invert filter on a paper-grey screen, serif justified text and a thin progress line. Tap the left or right side, or use the arrow keys. It fits book apps, publishers, reading trackers and newsletter previews.

The main color is the ink and the second the screen tone. Put your own paragraphs in the pages list and adjust the page numbers, and keep each page short enough to fit the screen.

## Code

### HTML

```html
<article class="uvq07-ink"><div class="sc" tabindex="0" aria-label="Book page, use the arrow keys to turn"><header><span>The Lighthouse Shadow</span><span>Chapter 3</span></header><p class="tx" aria-live="polite">The lighthouse had been dark for eleven years, but that night someone had climbed the stairs. From the harbour, Inés saw the light turn twice and stop, as if it were hesitating. She took her coat and the boat keys and left without waking anyone.</p><div class="br" aria-hidden="true"><i></i></div><footer><span><b class="pn">112</b> / 264</span><span><b class="pc">42</b> %</span></footer><button type="button" class="zl" aria-label="Previous page"></button><button type="button" class="zr" aria-label="Next page"></button></div><i class="hw" aria-hidden="true"></i></article>
```

### CSS

```css
.uvq07-ink {
  --c1: #262521;
  --c2: #e8e6dd;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq07-ink {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 15em;
  padding: .9em .9em 1.7em;
  border-radius: 1.3em;
  background: linear-gradient(160deg,#3c3d40,#222326);
  box-shadow: 0 1.4em 2.4em -1.2em rgba(0,0,0,.6),inset 0 1px 0 rgba(255,255,255,.12),0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent);
}

.uvq07-ink .sc {
  position: relative;
  padding: .9em 1em .75em;
  border-radius: .25em;
  color: var(--c1);
  background: radial-gradient(rgba(0,0,0,.05) .5px,transparent 1px) 0 0/3px 3px,var(--c2);
  box-shadow: inset 0 .1em .4em rgba(0,0,0,.35);
  outline: 0;
}

.uvq07-ink .sc:focus-visible {
  outline: 2px solid var(--c2);
  outline-offset: 4px;
}

.uvq07-ink header {
  display: flex;
  justify-content: space-between;
  gap: .6em;
  padding-bottom: .55em;
  font-size: .56em;
  letter-spacing: .03em;
  white-space: nowrap;
  text-transform: uppercase;
  opacity: .65;
  border-bottom: 1px solid color-mix(in srgb,var(--c1) 25%,transparent);
}

.uvq07-ink .tx {
  height: 11.4em;
  margin: .7em 0 .8em;
  overflow: hidden;
  font: 400 .8em/1.5 "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.uvq07-ink .br {
  height: 2px;
  margin-bottom: .5em;
  background: color-mix(in srgb,var(--c1) 18%,transparent);
}

.uvq07-ink .br i {
  display: block;
  height: 100%;
  width: 42%;
  background: var(--c1);
}

.uvq07-ink footer {
  display: flex;
  justify-content: space-between;
  font-size: .6em;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

.uvq07-ink .zl,.uvq07-ink .zr {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  border-radius: .25em;
}

.uvq07-ink .zl {
  left: 0;
  cursor: w-resize;
}

.uvq07-ink .zr {
  right: 0;
  cursor: e-resize;
}

.uvq07-ink .zl:focus-visible,.uvq07-ink .zr:focus-visible {
  outline: 2px dashed color-mix(in srgb,var(--c1) 55%,transparent);
  outline-offset: -4px;
}

.uvq07-ink .zl:active,.uvq07-ink .zr:active {
  background: color-mix(in srgb,var(--c1) 6%,transparent);
}

.uvq07-ink .sc.fl {
  animation: uvq07-ink calc(0.45s / var(--k)) steps(1,end);
}

.uvq07-ink .hw {
  position: absolute;
  left: 50%;
  bottom: .7em;
  width: 2.6em;
  height: .28em;
  margin-left: -1.3em;
  border-radius: 1em;
  background: rgba(255,255,255,.14);
}

@keyframes uvq07-ink {
  0% {
    filter: invert(1);
  }
  35% {
    filter: invert(1) contrast(.5);
  }
  60% {
    filter: none;
    opacity: .85;
  }
  100% {
    filter: none;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq07-ink,.uvq07-ink *,.uvq07-ink *::before,.uvq07-ink *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq07-ink").forEach(el => {
  const P=["The lighthouse had been dark for eleven years, but that night someone had climbed the stairs. From the harbour, Inés saw the light turn twice and stop, as if it were hesitating. She took her coat and the boat keys and left without waking anyone.","The tide was low and the stone path showed between the seaweed. Inés counted her steps the way her grandfather had taught her: sixty to the big rock and forty more to the door. It was open. Inside it smelled of paraffin and salt.","On the top step she found a notebook wrapped in oilcloth. The handwriting was small and tight, and the first page had her name written in blue ink. Outside, the light began to turn again, this time without stopping."];const sc=el.querySelector(".sc"),tx=el.querySelector(".tx"),pn=el.querySelector(".pn"),pc=el.querySelector(".pc"),br=el.querySelector(".br i");const sp=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;let k=0,t=0;
const turn=d=>{k=(k+d+P.length)%P.length;sc.classList.remove("fl");void sc.offsetWidth;sc.classList.add("fl");clearTimeout(t);
t=setTimeout(()=>{tx.textContent=P[k];const n=112+k,p=Math.round(n/264*100);pn.textContent=String(n);pc.textContent=String(p);br.style.width=p+"%"},140/sp)};
el.querySelector(".zl").addEventListener("click",()=>turn(-1));el.querySelector(".zr").addEventListener("click",()=>turn(1));
sc.addEventListener("keydown",e=>{if(e.target!==sc)return;if(e.key==="ArrowRight"||e.key===" "){e.preventDefault();turn(1)}if(e.key==="ArrowLeft"){e.preventDefault();turn(-1)}});
return()=>clearTimeout(t)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq07-ink {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 15em;
  padding: .9em .9em 1.7em;
  border-radius: 1.3em;
  background: linear-gradient(160deg,#3c3d40,#222326);
  box-shadow: 0 1.4em 2.4em -1.2em rgba(0,0,0,.6),inset 0 1px 0 rgba(255,255,255,.12),0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent);
}

.uvq07-ink .sc {
  position: relative;
  padding: .9em 1em .75em;
  border-radius: .25em;
  color: var(--c1);
  background: radial-gradient(rgba(0,0,0,.05) .5px,transparent 1px) 0 0/3px 3px,var(--c2);
  box-shadow: inset 0 .1em .4em rgba(0,0,0,.35);
  outline: 0;
}

.uvq07-ink .sc:focus-visible {
  outline: 2px solid var(--c2);
  outline-offset: 4px;
}

.uvq07-ink header {
  display: flex;
  justify-content: space-between;
  gap: .6em;
  padding-bottom: .55em;
  font-size: .56em;
  letter-spacing: .03em;
  white-space: nowrap;
  text-transform: uppercase;
  opacity: .65;
  border-bottom: 1px solid color-mix(in srgb,var(--c1) 25%,transparent);
}

.uvq07-ink .tx {
  height: 11.4em;
  margin: .7em 0 .8em;
  overflow: hidden;
  font: 400 .8em/1.5 "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.uvq07-ink .br {
  height: 2px;
  margin-bottom: .5em;
  background: color-mix(in srgb,var(--c1) 18%,transparent);
}

.uvq07-ink .br i {
  display: block;
  height: 100%;
  width: 42%;
  background: var(--c1);
}

.uvq07-ink footer {
  display: flex;
  justify-content: space-between;
  font-size: .6em;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

.uvq07-ink .zl,.uvq07-ink .zr {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  border-radius: .25em;
}

.uvq07-ink .zl {
  left: 0;
  cursor: w-resize;
}

.uvq07-ink .zr {
  right: 0;
  cursor: e-resize;
}

.uvq07-ink .zl:focus-visible,.uvq07-ink .zr:focus-visible {
  outline: 2px dashed color-mix(in srgb,var(--c1) 55%,transparent);
  outline-offset: -4px;
}

.uvq07-ink .zl:active,.uvq07-ink .zr:active {
  background: color-mix(in srgb,var(--c1) 6%,transparent);
}

.uvq07-ink .sc.fl {
  animation: uvq07-ink calc(0.45s / var(--k)) steps(1,end);
}

.uvq07-ink .hw {
  position: absolute;
  left: 50%;
  bottom: .7em;
  width: 2.6em;
  height: .28em;
  margin-left: -1.3em;
  border-radius: 1em;
  background: rgba(255,255,255,.14);
}

@keyframes uvq07-ink {
  0% {
    filter: invert(1);
  }
  35% {
    filter: invert(1) contrast(.5);
  }
  60% {
    filter: none;
    opacity: .85;
  }
  100% {
    filter: none;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq07-ink,.uvq07-ink *,.uvq07-ink *::before,.uvq07-ink *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const P=["The lighthouse had been dark for eleven years, but that night someone had climbed the stairs. From the harbour, Inés saw the light turn twice and stop, as if it were hesitating. She took her coat and the boat keys and left without waking anyone.","The tide was low and the stone path showed between the seaweed. Inés counted her steps the way her grandfather had taught her: sixty to the big rock and forty more to the door. It was open. Inside it smelled of paraffin and salt.","On the top step she found a notebook wrapped in oilcloth. The handwriting was small and tight, and the first page had her name written in blue ink. Outside, the light began to turn again, this time without stopping."];const sc=el.querySelector(".sc"),tx=el.querySelector(".tx"),pn=el.querySelector(".pn"),pc=el.querySelector(".pc"),br=el.querySelector(".br i");const sp=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;let k=0,t=0;
const turn=d=>{k=(k+d+P.length)%P.length;sc.classList.remove("fl");void sc.offsetWidth;sc.classList.add("fl");clearTimeout(t);
t=setTimeout(()=>{tx.textContent=P[k];const n=112+k,p=Math.round(n/264*100);pn.textContent=String(n);pc.textContent=String(p);br.style.width=p+"%"},140/sp)};
el.querySelector(".zl").addEventListener("click",()=>turn(-1));el.querySelector(".zr").addEventListener("click",()=>turn(1));
sc.addEventListener("keydown",e=>{if(e.target!==sc)return;if(e.key==="ArrowRight"||e.key===" "){e.preventDefault();turn(1)}if(e.key==="ArrowLeft"){e.preventDefault();turn(-1)}});
return()=>clearTimeout(t)
}

export default function CardEinkReader() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#262521",
          "--c2": "#e8e6dd",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <article className="uvq07-ink"><div className="sc" tabIndex={0} aria-label="Book page, use the arrow keys to turn"><header><span>The Lighthouse Shadow</span><span>Chapter 3</span></header><p className="tx" aria-live="polite">The lighthouse had been dark for eleven years, but that night someone had climbed the stairs. From the harbour, Inés saw the light turn twice and stop, as if it were hesitating. She took her coat and the boat keys and left without waking anyone.</p><div className="br" aria-hidden="true"><i></i></div><footer><span><b className="pn">112</b> / 264</span><span><b className="pc">42</b> %</span></footer><button type="button" className="zl" aria-label="Previous page"></button><button type="button" className="zr" aria-label="Next page"></button></div><i className="hw" aria-hidden="true"></i></article>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “E-ink reader page” block (Cards) from AIMRAN Library to my project.

## What it is
A novel page on an e-ink screen: turning the page triggers the typical negative flash and moves the progress bar.

## Chosen settings
- Main color: #262521
- Secondary color: #e8e6dd
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "La sombra del faro"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq07-ink {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 15em;
  padding: .9em .9em 1.7em;
  border-radius: 1.3em;
  background: linear-gradient(160deg,#3c3d40,#222326);
  box-shadow: 0 1.4em 2.4em -1.2em rgba(0,0,0,.6),inset 0 1px 0 rgba(255,255,255,.12),0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent);
}

.uvq07-ink .sc {
  position: relative;
  padding: .9em 1em .75em;
  border-radius: .25em;
  color: var(--c1);
  background: radial-gradient(rgba(0,0,0,.05) .5px,transparent 1px) 0 0/3px 3px,var(--c2);
  box-shadow: inset 0 .1em .4em rgba(0,0,0,.35);
  outline: 0;
}

.uvq07-ink .sc:focus-visible {
  outline: 2px solid var(--c2);
  outline-offset: 4px;
}

.uvq07-ink header {
  display: flex;
  justify-content: space-between;
  gap: .6em;
  padding-bottom: .55em;
  font-size: .56em;
  letter-spacing: .03em;
  white-space: nowrap;
  text-transform: uppercase;
  opacity: .65;
  border-bottom: 1px solid color-mix(in srgb,var(--c1) 25%,transparent);
}

.uvq07-ink .tx {
  height: 11.4em;
  margin: .7em 0 .8em;
  overflow: hidden;
  font: 400 .8em/1.5 "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.uvq07-ink .br {
  height: 2px;
  margin-bottom: .5em;
  background: color-mix(in srgb,var(--c1) 18%,transparent);
}

.uvq07-ink .br i {
  display: block;
  height: 100%;
  width: 42%;
  background: var(--c1);
}

.uvq07-ink footer {
  display: flex;
  justify-content: space-between;
  font-size: .6em;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

.uvq07-ink .zl,.uvq07-ink .zr {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  border-radius: .25em;
}

.uvq07-ink .zl {
  left: 0;
  cursor: w-resize;
}

.uvq07-ink .zr {
  right: 0;
  cursor: e-resize;
}

.uvq07-ink .zl:focus-visible,.uvq07-ink .zr:focus-visible {
  outline: 2px dashed color-mix(in srgb,var(--c1) 55%,transparent);
  outline-offset: -4px;
}

.uvq07-ink .zl:active,.uvq07-ink .zr:active {
  background: color-mix(in srgb,var(--c1) 6%,transparent);
}

.uvq07-ink .sc.fl {
  animation: uvq07-ink calc(0.45s / var(--k)) steps(1,end);
}

.uvq07-ink .hw {
  position: absolute;
  left: 50%;
  bottom: .7em;
  width: 2.6em;
  height: .28em;
  margin-left: -1.3em;
  border-radius: 1em;
  background: rgba(255,255,255,.14);
}

@keyframes uvq07-ink {
  0% {
    filter: invert(1);
  }
  35% {
    filter: invert(1) contrast(.5);
  }
  60% {
    filter: none;
    opacity: .85;
  }
  100% {
    filter: none;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq07-ink,.uvq07-ink *,.uvq07-ink *::before,.uvq07-ink *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const P=["The lighthouse had been dark for eleven years, but that night someone had climbed the stairs. From the harbour, Inés saw the light turn twice and stop, as if it were hesitating. She took her coat and the boat keys and left without waking anyone.","The tide was low and the stone path showed between the seaweed. Inés counted her steps the way her grandfather had taught her: sixty to the big rock and forty more to the door. It was open. Inside it smelled of paraffin and salt.","On the top step she found a notebook wrapped in oilcloth. The handwriting was small and tight, and the first page had her name written in blue ink. Outside, the light began to turn again, this time without stopping."];const sc=el.querySelector(".sc"),tx=el.querySelector(".tx"),pn=el.querySelector(".pn"),pc=el.querySelector(".pc"),br=el.querySelector(".br i");const sp=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;let k=0,t=0;
const turn=d=>{k=(k+d+P.length)%P.length;sc.classList.remove("fl");void sc.offsetWidth;sc.classList.add("fl");clearTimeout(t);
t=setTimeout(()=>{tx.textContent=P[k];const n=112+k,p=Math.round(n/264*100);pn.textContent=String(n);pc.textContent=String(p);br.style.width=p+"%"},140/sp)};
el.querySelector(".zl").addEventListener("click",()=>turn(-1));el.querySelector(".zr").addEventListener("click",()=>turn(1));
sc.addEventListener("keydown",e=>{if(e.target!==sc)return;if(e.key==="ArrowRight"||e.key===" "){e.preventDefault();turn(1)}if(e.key==="ArrowLeft"){e.preventDefault();turn(-1)}});
return()=>clearTimeout(t)
}

export default function CardEinkReader() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#262521",
          "--c2": "#e8e6dd",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <article className="uvq07-ink"><div className="sc" tabIndex={0} aria-label="Book page, use the arrow keys to turn"><header><span>The Lighthouse Shadow</span><span>Chapter 3</span></header><p className="tx" aria-live="polite">The lighthouse had been dark for eleven years, but that night someone had climbed the stairs. From the harbour, Inés saw the light turn twice and stop, as if it were hesitating. She took her coat and the boat keys and left without waking anyone.</p><div className="br" aria-hidden="true"><i></i></div><footer><span><b className="pn">112</b> / 264</span><span><b className="pc">42</b> %</span></footer><button type="button" className="zl" aria-label="Previous page"></button><button type="button" className="zr" aria-label="Next page"></button></div><i className="hw" aria-hidden="true"></i></article>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
