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
spansis the night in order. Each span has astage(awake,rem,light, ordeep), astart, and anendasHH: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.
heightsets the height in pixels (default 180). The chart takes the width of its box.- Change the words with
labelsor a label pack:title, the four stages, and the functionstotalandhours.
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
| Name | Type | Default | Description |
|---|---|---|---|
spans* | BlessSleepSpan[] | — | |
height | number | 180 | |
labels | Partial<Record<BlessSleepStage, string> & { title: string; total: (time: string) => string; hours: (h: number, m: number) => string; }> | — |