# Sleep Stages

> A week of sleep with a hypnogram per night: a block for every stretch of awake, REM, light and deep sleep, joined by a thin step, with the score and time asleep above. A strip of nights with score bars switches the chart, and the time asleep counts to each night. Each stage's share sits against its typical range; hovering a stage lifts its blocks, and scrubbing lifts the stretch under the cursor and reads its time and length.

## Spec sheet

| | |
| --- | --- |
| Access | Free: no account, free for commercial use |
| Shelf | Blocks › Charts |
| Live preview | https://uibrik.com/components/sleep-stages |
| Writes | 1 file into `components/uibrik/sleep-stages/` |
| Packages | `motion` (the CLI installs them) |
| Needs | React 19, Tailwind CSS v4, a project set up with `npx shadcn@latest init` |
| Theme | Reads the shadcn tokens and follows class-based dark mode ([theming](https://uibrik.com/docs/theming.md)) |
| Updated | Nov 26, 2026 |

## Add it

```bash
npx shadcn@latest add https://uibrik.com/r/sleep-stages.json
```

With the `@uibrik` namespace in `components.json` ([setup](https://uibrik.com/docs/installation.md)): `npx shadcn@latest add @uibrik/sleep-stages`.

Can't run commands? https://uibrik.com/components/sleep-stages/prompt.txt has every file verbatim, with the setup steps, ready for an assistant to write.

## Render it

Renders as is; every value shown is the default, so delete any line you don't need.

```tsx
import { SleepStages } from "@/components/uibrik/sleep-stages/sleep-stages";

<SleepStages
  title="Sleep"
  color="#6e56cf"
  hour24={false}
  width={460}
  // nights={[{ label: "…", bedtime: "…", segments: […] }]}
  // defaultNight={0}
  // onNightChange={(index) => {}}
  // segments={[{ stage: "awake", minutes: 0 }]}
/>
```

## Tune it

The same props as the Customize panel on https://uibrik.com/components/sleep-stages.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `title` | `string` | `"Sleep"` | Heading above the chart. |
| `color` | `string` | `"#6e56cf"` | Hue the stages are shaded from. Awake stays neutral. |
| `hour24` | `boolean` | `false` | Show times in 24-hour format. |
| `width` | `number` | `460` | Width of the card; never wider than its container. |

## Wire it

The props the Customize panel doesn't show: ranges, data, content and callbacks.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `nights` | `{ label: string; bedtime: string; score?: number; segments: SleepSegment[] }[]` |  | Several nights, oldest first, with a strip to switch between them. Overrides segments, bedtime and score. |
| `defaultNight / onNightChange` | `number / (index) => void` |  | Night shown on mount (defaults to the last) and a callback when it changes. |
| `segments` | `{ stage: "awake" \| "rem" \| "light" \| "deep"; minutes: number }[]` |  | A single night in order, one entry per stretch in a stage; shown without the week strip. |
| `className` | `string` |  | Classes for the wrapper. |

## Where it fits

- **Health and wearable apps**: The whole night reads in one chart, and scrubbing answers when each stage happened. Pairs with [Daily Rings](https://uibrik.com/components/daily-rings.md) (Pro).
- **Wellness dashboards**: Typical ranges next to each stage say whether a number is good without a separate legend. Pairs with [Streak Calendar](https://uibrik.com/components/streak-calendar.md) (Pro).
- **Sleep tracker landing pages**: A hypnogram that draws in shows what the device measures before any copy does.

## Same shelf: Charts

- [Split Bar](https://uibrik.com/components/split-bar.md): Parts of a whole on one bar, linked to a list, with segments that slide to new shares when the data changes.
- [Stacked Bars](https://uibrik.com/components/stacked-bars.md) (Pro): Monthly columns split by series that slide apart into groups, with a legend that folds series away.
- [Stock Chart](https://uibrik.com/components/stock-chart.md) (Pro): A live candlestick stock chart with seven ranges, volume, RSI and moving averages, earnings markers, drag-to-measure and key statistics.
- [Table Chart](https://uibrik.com/components/table-chart.md) (Pro): A table whose share bars lift out one by one and swing upright into the bars of a chart, while the labels and headers slide into place as its axes.
- [Tide Chart](https://uibrik.com/components/tide-chart.md) (Pro): A streamgraph of flowing bands: point at one to follow it, click it to fold the rest away, click again to open it into its parts, in shades of its colour.
- [Area Chart](https://uibrik.com/components/area-chart.md): A time-series chart with soft area washes and one crosshair that reads every series at once.

## Ground rules

- Only the props above exist. To change anything else, edit the installed file.
- Keep the files in `components/uibrik/sleep-stages/` so the import paths keep resolving.
- The playbook for working with the whole library: https://uibrik.com/llms.txt
