SwipeUI

Time-of-day card

A daily summary over morning, afternoon and night skies that follow the local device clock.

npx @swipeui/cli add time-of-day-card
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • A daily focus summary with a greeting and progress.
  • A home-screen status card that follows local time.
  • A calm illustrated surface for two supporting stats.
  • An explicitly chosen morning, afternoon or night mood.

When not to use it

  • Dense facts: use table-card.
  • A single number with a trend: use metric-card.
  • Interactive scheduling: use time-picker.
  • Photographic content: use a listing card.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add time-of-day-card
  • Adds components/swipeui/card/time-of-day-card.tsx, components/swipeui/card/time-of-day-sky.tsx, components/swipeui/card/time-of-day-palette.ts, components/swipeui/card/use-time-of-day.ts and 5 shared helpers.
  • Installs class-variance-authority, react-native-svg, react-native-reanimated, clsx, tailwind-merge, react-native-worklets. In Expo apps it uses npx expo install so versions match your SDK.

Usage

daily-focus.tsx
import { TimeOfDayCard } from '@/components/swipeui/card/time-of-day-card';

<TimeOfDayCard value="0m" caption="focused today"
  stats={[{ label: 'Sessions', value: '0' }, { label: 'Daily Goal', value: '0%' }]}
  progress={0} progressLabel="Daily goal" />;

Examples

quiet-evening.tsx
import { TimeOfDayCard } from '@/components/swipeui/card/time-of-day-card';

<TimeOfDayCard period="night" value="45m" caption="focused today" glow={false} haze={false} drift={false} />;
fixed-clock.tsx
import { TimeOfDayCard } from '@/components/swipeui/card/time-of-day-card';

<TimeOfDayCard period="auto" now={new Date(2026, 10, 3, 8)} value="20m"
  greeting={{ morning: 'A fresh start', afternoon: 'Keep going', night: 'Time to rest' }} />;

Glass appearance

The Glass preset changes the demo’s period and playback controls. The daily summary, sky and progress bar keep their own appearance.

API reference

PropTypeDefaultDescription
valuestring—

The main formatted value, for example "0m".

period?"auto" | TimeOfDayPeriod'auto'

Local-clock sky, or an explicit caller-controlled period.

now?Dateundefined

Fixed clock input for auto mode; omitted follows the device each minute and on resume.

greeting?string | Record<TimeOfDayPeriod, string>Good morning / Good afternoon / Good evening

Greeting text, or text per resolved period.

caption?stringundefined

Supporting text below the value.

stats?readonly TimeOfDayStat[][]

Supporting label/value pairs, wrapping as space allows.

statsBackground?objectundefined

Optional material behind the stats; text follows the app theme.

progress?numberundefined

Fraction clamped to 0–1; omitted hides the track. NaN is treated as zero.

progressBackground?objectundefined

Optional material for the track, below the theme-colored fill.

progressLabel?string'Progress'

Spoken name for the progress fraction.

palette?Partial<Record<TimeOfDayPeriod, Partial<TimeOfDayPalette>>>TIME_OF_DAY_PALETTES

Override individual artwork and text swatches per period.

celestial?booleantrue

Draw the sun or moon.

stars?booleantrue

Draw deterministic stars during night.

hills?booleantrue

Draw both hill silhouettes.

haze?booleantrue

Draw the faint drifting haze; always hidden under Reduce Transparency.

glow?booleantrue

Draw the radial halo; always hidden under Reduce Transparency.

animated?booleantrue

Master motion switch. Each motion can also be switched independently.

crossFade?booleantrue

Fade sky layers when the period changes.

animateCelestial?booleantrue

Ease the sun/moon to its new position; reduced motion places it immediately.

drift?booleantrue

Slowly drift the haze while visible and foregrounded.

motion?MotionOverridethe app's feel

Shared morph, layout and ambient character.

children?ReactNodeundefined

Replace the entire content block. Supply accessibilityLabel for custom content.

accessibilityLabel?stringgreeting, value, caption, stats and labelled progress

Spoken summary.

className?stringundefined

Classes merged over the surface.

style?StyleProp<ViewStyle>undefined

Native surface style.

testID?stringundefined

Root identifier; parts append their names.

Composition and behavior

  • The surface is always elevated with the shared raised shadow in every period and theme.

  • This is a display card. Place Morning / Afternoon / Night / Auto buttons below it, with selection state and haptics owned by those controls.

  • auto uses local hours: 05:00–11:59 morning, 12:00–17:59 afternoon, otherwise night. It reads the device clock each minute in the foreground and on return. now fixes that clock input.

  • Three stable sky layers cross-fade. The celestial body moves between period positions; haze drifts while visible and foregrounded. Each animation and each art layer has its own switch.

  • Reduce Motion gives a short cross-fade, immediate body placement and a still haze. Reduce Transparency removes the glow and haze.

  • Text grows and stats wrap. The summary includes progress; the visual track is hidden from screen readers. children replaces the entire default content block and needs a custom accessibilityLabel.

  • Partial palettes override swatches per period. Check contrast for your artwork and text colours.

Sky and content settings

PropDoesDefault
valueMain formatted valueRequired
periodExplicit sky or local-clock autoauto
nowFixed Date input for autoDevice clock
greetingString or one greeting per periodGood morning / Good afternoon / Good evening
captionSupporting copyNone
statsLabel/value pairsEmpty
statsBackgroundDecorative stats materialNone
progressClamped fraction; omitted hides the trackNone
progressBackgroundDecorative progress-track materialNone
progressLabelSpoken progress nameProgress
palettePartial per-period swatchesBuilt-in palettes
celestialSun or moon disctrue
glowRadial halotrue; suppressed by Reduce Transparency
starsStars at nighttrue
hillsTwo wave silhouettestrue
hazeFaint hazetrue; suppressed by Reduce Transparency
animatedMaster animation switchtrue
crossFadePeriod cross-fadestrue
animateCelestialBody traveltrue
driftAmbient haze motiontrue
motionMorph, layout and ambient feelApp feel
childrenEntire custom content blockDefault summary layout
accessibilityLabelCustom spoken summaryComposed content
className / styleRoot stylingNone
testIDRoot and part identifiersNone

Behavior and gestures

  • Set statsBackground and progressBackground independently to add material over the sky.
  • period selects morning, afternoon, night or auto; now fixes the auto clock for previews and tests.
  • auto reads local hours, refreshes each minute in the foreground and resyncs on return; it is not a timezone or sunrise calculator.
  • The card itself has no action or haptic. Place selection buttons outside it, with their own haptics prop.
  • celestial, stars, hills, haze and glow each switch their own artwork layer. Stars appear only at night.
  • animated is the master switch; crossFade, animateCelestial and drift independently control transitions, body travel and ambient haze.
  • value, greeting, caption, stats, progress and progressLabel control all default content. children replaces that block. palette overrides individual swatches per period.

Accessibility

  • One summary joins the greeting, value, caption, stats and labelled progress. Custom children need accessibilityLabel.
  • Text wraps and grows; the decorative artwork and progress track are hidden from screen readers because progress is already in the summary.
  • RTL mirrors the artwork and the row flow. Progress fills from the reading start.
  • Reduce Motion keeps a short cross-fade and a still haze with instant body placement. Reduce Transparency removes glow and haze.

Motion

  • Uses the morph, layout and ambient motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Stable sky layers cross-fade on morph and their bodies ease on layout. Rapid changes retarget the same layers.
  • Haze drifts on ambient only while visible and foregrounded; reduced motion keeps it still.
  • animated=false stops all animation; each sub-behaviour has its own switch.

Performance

  • Three stable SVG skies with deterministic stars and per-instance gradient IDs; motion runs on the UI thread.
  • Auto uses one minute timer only when no fixed now is supplied; ambient lifecycle uses the shared visibility/background hook.

Notes for AI

  • Pass period explicitly for deterministic screens, or now with period auto for a fixed local-clock preview.
  • Keep period controls outside the card. It is display-only, so no unused haptics or internal selection-state props are exposed.
  • Use palette for artwork and verify custom text contrast; supply accessibilityLabel for custom children.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items