Skip to content
Calm motion: animations on this site only fade, with no movement

Sleep chart ​

The stages of sleep across a night

Shows one night from a sleep tracker. This kind of chart is a hypnogram: each stage has its own row, so the stage shows by its height and not only by its color.

Basic
AwakeREMLightDeep00:0001:0002:0003:0004:0005:0006:00
Asleep 6 h 50 min Awake 35 min REM 1 h 15 min Light 3 h 40 min Deep 1 h 55 min
  • spans is the night in order. Each span has a stage (awake, rem, light, or deep), a start, and an end as HH:MM.
  • A time before the first start is on the next day, so a night can cross midnight.
  • Awake is on top and deep sleep is at the bottom. Ticks mark each full hour of the clock.
  • Under the chart, the totals show the time asleep and the time in each stage. Screen readers hear the same totals as the name of the chart.
  • height sets the height in pixels (default 180). The chart takes the width of its box.
  • Change the words with labels or a label pack: title, the four stages, and the functions total and hours.

The sleepSpans function turns the clock times into minutes from the start. It is exported for your own views.

Usage ​

ts
import { BlessSleepChart } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
spans*BlessSleepSpan[]—
heightnumber180
labelsPartial<Record<BlessSleepStage, string> & { title: string; total: (time: string) => string; hours: (h: number, m: number) => string; }>—

Released under the MIT License. Character names and artwork belong to their owners.