v0.1 public beta early access on GitHub
Home / Screens / health-sleep-tracker
Screen template

Sleep Tracker Screen

Sleep score, stages, and schedule

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light · selection
$ npx lumioui add health-sleep-tracker
import { SleepTrackerScreen } from "@/screens/health/sleep-tracker";
Registry dependencies5
Native packages installed6
@lumioui/ui@latestreact-native-safe-area-context@*@lumioui/core@latestreact-native-reanimated@*react-native-svg@*nativewind@*
health/sleep-tracker.tsxsource · yours to edit
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Icon, ProgressRing, Text } from "@lumioui/ui";
import { GlowSpot, Mount } from "../shared";

export interface SleepStage {
  id: string;
  name: string;
  span: string;
  /** 0–1 bar fraction. */
  share: number;
  color: string;
}

export interface SleepTrackerScreenProps {
  night?: string;
  /** "7h 24m" */
  duration?: string;
  score?: number;
  stages?: SleepStage[];
  onBack?: () => void;
}

const DEFAULT_STAGES: SleepStage[] = [
  { id: "deep", name: "Deep", span: "11:10 PM – 12:40 AM", share: 0.2, color: "bg-[#4338CA]" },
  { id: "core", name: "Core", span: "12:40 AM – 4:50 AM", share: 0.54, color: "bg-[#818CF8]" },
  { id: "rem", name: "REM", span: "4:50 AM – 6:34 AM", share: 0.23, color: "bg-[#C7D2FE]" },
  { id: "awake", name: "Awake", span: "6:34 AM – 6:50 AM", share: 0.03, color: "bg-[#FBBF24]" },
];

/** Sleep tracker — night stage: a scheme-fixed deep-indigo world (sleep data
 *  is reviewed at night and the dark stage IS the art direction), score ring
 *  hero, stacked stage bar, schedule row. */
export function SleepTrackerScreen({
  night = "Last night",
  duration = "7h 24m",
  score = 82,
  stages = DEFAULT_STAGES,
  onBack,
}: SleepTrackerScreenProps) {
  const insets = useSafeAreaInsets();

  return (
    <SafeAreaView className="flex-1 bg-[#131633]" edges={["top"]}>
      <GlowSpot color="#6366F1" size={300} className="-top-20 left-[-80px]" />
      <GlowSpot color="#FBBF24" size={200} className="bottom-[25%] right-[-100px]" />
      <GlowSpot color="#4F46E5" size={300} className="-left-24 top-6" />
      <GlowSpot color="#7C3AED" size={220} className="-right-16 top-40" />
      <View className="flex-row items-center gap-2 px-4 pb-1 pt-2">
        <Button
          variant="ghost"
          size="icon"
          haptic="light"
          onPress={() => onBack?.()}
          accessibilityLabel="Go back"
          className="-ml-2 h-10 w-10"
        >
          <Icon name="chevron-left" size="md" color="#FFF" />
        </Button>
        <Text className="text-lg font-semibold text-white" accessibilityRole="header">
          Sleep
        </Text>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingBottom: insets.bottom + 32 }}
      >
        {/* Score + duration — the two numbers sleep apps lead with. */}
        <Mount delay={0}>
          <View className="items-center py-4">
            <ProgressRing value={score} size={144} strokeWidth={10} color="chart3" label={`Sleep score ${score}`}>
              <View className="items-center">
                <Text className="text-4xl font-light text-white">{score}</Text>
                <Text className="text-xs text-white/50">score</Text>
              </View>
            </ProgressRing>
            <Text className="mt-3 text-3xl font-bold tracking-tight text-white">{duration}</Text>
            <Text className="mt-1 text-sm text-white/50">
              {night} · 11:10 PM – 6:50 AM
            </Text>
            {/* Goal context — scores land against a target. */}
            <Text className="mt-1 text-xs text-white/40">
              Goal 8h — hit 4 of 7 nights this week
            </Text>
          </View>
        </Mount>

        {/* Stages — stacked bar, then rows per stage. */}
        <Mount delay={120}>
          <View className="mx-4 mb-4">
            <View className="h-4 w-full flex-row overflow-hidden rounded-full">
              {stages.map((s) => (
                <View
                  key={s.id}
                  className={s.color}
                  style={{ width: `${s.share * 100}%` }}
                  accessibilityElementsHidden
                />
              ))}
            </View>
          </View>

          <View className="px-4 pb-1.5">
            <Text className="text-xs font-medium uppercase tracking-wide text-white/40">
              Stages
            </Text>
          </View>
          <View className="mx-4 mb-6 gap-4 rounded-3xl bg-white/[0.07] p-4">
            {stages.map((s) => (
              <View key={s.id} className="flex-row items-center gap-3">
                <View className={`h-8 w-2 rounded-full ${s.color}`} />
                <View className="flex-1">
                  <Text className="text-sm font-medium text-white">{s.name}</Text>
                  <Text className="text-xs text-white/50">{s.span}</Text>
                </View>
                <Text className="text-sm font-medium text-white">
                  {Math.round(s.share * 100)}%
                </Text>
              </View>
            ))}
          </View>
        </Mount>

        {/* Schedule row — bedtime/wake is the actionable half of sleep. */}
        <Mount delay={220}>
          <View className="mx-4 flex-row items-center gap-3 rounded-3xl bg-white/[0.07] p-4">
            <View className="h-10 w-10 items-center justify-center rounded-2xl bg-[#818CF8]/20">
              <Icon name="moon" size="sm" color="#A5B4FC" />
            </View>
            <View className="flex-1">
              <Text className="text-sm font-semibold text-white">Schedule</Text>
              <Text className="text-xs text-white/50">
                Bedtime 11:00 PM · Wake 7:00 AM
              </Text>
            </View>
            <Icon name="chevron-right" size="sm" color="#A5B4FC" />
          </View>
        </Mount>
      </ScrollView>
    </SafeAreaView>
  );
}
SleepTrackerScreen.displayName = "SleepTrackerScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Sleep Tracker Screen" screen in React Native using LumioUI.

Goal: Sleep score, stages, and schedule Match the reference implementation's layout, behavior, and motion exactly — this is a production screen, not a mockup.

## Setup

Fastest path — install the screen plus its component deps:

```bash
npx lumioui add health-sleep-tracker
```

Or pull just the components: `npx lumioui add button icon list progress-ring text`

Native packages:
- @lumioui/ui@latest
- react-native-safe-area-context@*
- @lumioui/core@latest
- react-native-reanimated@*
- react-native-svg@*
- nativewind@*

Stack assumptions: Expo SDK 54 / RN 0.81, Reanimated 4, NativeWind v4, TypeScript strict, Expo Go compatible.

## Components — how, where, when

### `button` — Tactile pill button with press spring, ink wash and async loading.
- `<Button>` ×1

### `icon` — Lucide icon set mapped to theme colors and sizes.
- `<Icon>` ×3

### `list` — Settings-style rows with separators and press feedback.
- imported but not rendered directly — likely used through a sibling or as a utility

### `progress-ring` — Circular progress ring with animated stroke arc, center slot and indeterminate spin.
- `<ProgressRing>` ×1

### `text` — Themed type scale from caption to display.
- `<Text>` ×12

## Conventions (non-negotiable)

- Styling via NativeWind `className` with semantic tokens only: `bg-background`, `text-foreground`, `bg-card`, `text-card-foreground`, `bg-secondary`, `bg-muted`, `text-muted-foreground`, `bg-accent`, `bg-destructive`, `border-border`. Hard-coded colors only inside media overlays (`text-white`, `bg-black/N`).
- Motion via the token presets from `@lumioui/core` (`spring.press`, `spring.surface`, `spring.glide`, `timing.fast`, `timing.slow`, …) — no bespoke spring configs or durations.
- Gate transform motion behind `useReducedMotion()`; keep opacity/color feedback, drop travel and overshoot.
- Haptics via `useHaptic()`: `light` on press, `selection` on toggle/select, `warning` on invalid input. Never import expo-haptics directly.
- Press feedback via `usePressAnimation()` (~0.97 scale), not `activeOpacity` tricks.
- a11y: `accessibilityRole` + `accessibilityLabel` on every control, touch targets ≥44pt.
- Entrance choreography: staggered `Mount` wrappers (delay 0/60/120…) so regions land in sequence instead of popping in at once.
- Wrap the screen in `SafeAreaView`; keep dark mode working via the semantic tokens.

## Deliverable

One file: `screens/health/sleep-tracker.tsx` exporting SleepTrackerScreen. Preserve the props interface — the host app wires the callbacks (navigation, submit handlers) through them.

## Reference implementation

The LumioUI source for this screen — reproduce it faithfully:

```tsx
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Icon, ProgressRing, Text } from "@lumioui/ui";
import { GlowSpot, Mount } from "../shared";

export interface SleepStage {
  id: string;
  name: string;
  span: string;
  /** 0–1 bar fraction. */
  share: number;
  color: string;
}

export interface SleepTrackerScreenProps {
  night?: string;
  /** "7h 24m" */
  duration?: string;
  score?: number;
  stages?: SleepStage[];
  onBack?: () => void;
}

const DEFAULT_STAGES: SleepStage[] = [
  { id: "deep", name: "Deep", span: "11:10 PM – 12:40 AM", share: 0.2, color: "bg-[#4338CA]" },
  { id: "core", name: "Core", span: "12:40 AM – 4:50 AM", share: 0.54, color: "bg-[#818CF8]" },
  { id: "rem", name: "REM", span: "4:50 AM – 6:34 AM", share: 0.23, color: "bg-[#C7D2FE]" },
  { id: "awake", name: "Awake", span: "6:34 AM – 6:50 AM", share: 0.03, color: "bg-[#FBBF24]" },
];

/** Sleep tracker — night stage: a scheme-fixed deep-indigo world (sleep data
 *  is reviewed at night and the dark stage IS the art direction), score ring
 *  hero, stacked stage bar, schedule row. */
export function SleepTrackerScreen({
  night = "Last night",
  duration = "7h 24m",
  score = 82,
  stages = DEFAULT_STAGES,
  onBack,
}: SleepTrackerScreenProps) {
  const insets = useSafeAreaInsets();

  return (
    <SafeAreaView className="flex-1 bg-[#131633]" edges={["top"]}>
      <GlowSpot color="#6366F1" size={300} className="-top-20 left-[-80px]" />
      <GlowSpot color="#FBBF24" size={200} className="bottom-[25%] right-[-100px]" />
      <GlowSpot color="#4F46E5" size={300} className="-left-24 top-6" />
      <GlowSpot color="#7C3AED" size={220} className="-right-16 top-40" />
      <View className="flex-row items-center gap-2 px-4 pb-1 pt-2">
        <Button
          variant="ghost"
          size="icon"
          haptic="light"
          onPress={() => onBack?.()}
          accessibilityLabel="Go back"
          className="-ml-2 h-10 w-10"
        >
          <Icon name="chevron-left" size="md" color="#FFF" />
        </Button>
        <Text className="text-lg font-semibold text-white" accessibilityRole="header">
          Sleep
        </Text>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingBottom: insets.bottom + 32 }}
      >
        {/* Score + duration — the two numbers sleep apps lead with. */}
        <Mount delay={0}>
          <View className="items-center py-4">
            <ProgressRing value={score} size={144} strokeWidth={10} color="chart3" label={`Sleep score ${score}`}>
              <View className="items-center">
                <Text className="text-4xl font-light text-white">{score}</Text>
                <Text className="text-xs text-white/50">score</Text>
              </View>
            </ProgressRing>
            <Text className="mt-3 text-3xl font-bold tracking-tight text-white">{duration}</Text>
            <Text className="mt-1 text-sm text-white/50">
              {night} · 11:10 PM – 6:50 AM
            </Text>
            {/* Goal context — scores land against a target. */}
            <Text className="mt-1 text-xs text-white/40">
              Goal 8h — hit 4 of 7 nights this week
            </Text>
          </View>
        </Mount>

        {/* Stages — stacked bar, then rows per stage. */}
        <Mount delay={120}>
          <View className="mx-4 mb-4">
            <View className="h-4 w-full flex-row overflow-hidden rounded-full">
              {stages.map((s) => (
                <View
                  key={s.id}
                  className={s.color}
                  style={{ width: `${s.share * 100}%` }}
                  accessibilityElementsHidden
                />
              ))}
            </View>
          </View>

          <View className="px-4 pb-1.5">
            <Text className="text-xs font-medium uppercase tracking-wide text-white/40">
              Stages
            </Text>
          </View>
          <View className="mx-4 mb-6 gap-4 rounded-3xl bg-white/[0.07] p-4">
            {stages.map((s) => (
              <View key={s.id} className="flex-row items-center gap-3">
                <View className={`h-8 w-2 rounded-full ${s.color}`} />
                <View className="flex-1">
                  <Text className="text-sm font-medium text-white">{s.name}</Text>
                  <Text className="text-xs text-white/50">{s.span}</Text>
                </View>
                <Text className="text-sm font-medium text-white">
                  {Math.round(s.share * 100)}%
                </Text>
              </View>
            ))}
          </View>
        </Mount>

        {/* Schedule row — bedtime/wake is the actionable half of sleep. */}
        <Mount delay={220}>
          <View className="mx-4 flex-row items-center gap-3 rounded-3xl bg-white/[0.07] p-4">
            <View className="h-10 w-10 items-center justify-center rounded-2xl bg-[#818CF8]/20">
              <Icon name="moon" size="sm" color="#A5B4FC" />
            </View>
            <View className="flex-1">
              <Text className="text-sm font-semibold text-white">Schedule</Text>
              <Text className="text-xs text-white/50">
                Bedtime 11:00 PM · Wake 7:00 AM
              </Text>
            </View>
            <Icon name="chevron-right" size="sm" color="#A5B4FC" />
          </View>
        </Mount>
      </ScrollView>
    </SafeAreaView>
  );
}
SleepTrackerScreen.displayName = "SleepTrackerScreen";
```

Screen: https://lumioui.dev/screens/health-sleep-tracker
iPhone 17 · iOS
9:41
Live preview — the real screen via Expo Web · open full ↗