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-cardWhen 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.tsand 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 installso versions match your SDK.
Usage
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
import { TimeOfDayCard } from '@/components/swipeui/card/time-of-day-card';
<TimeOfDayCard period="night" value="45m" caption="focused today" glow={false} haze={false} drift={false} />;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
| Prop | Type | Default | Description |
|---|---|---|---|
value | | — | The main formatted value, for example "0m". |
period? | | | Local-clock sky, or an explicit caller-controlled period. |
now? | | | Fixed clock input for auto mode; omitted follows the device each minute and on resume. |
greeting? | | | Greeting text, or text per resolved period. |
caption? | | | Supporting text below the value. |
stats? | | | Supporting label/value pairs, wrapping as space allows. |
statsBackground? | | | Optional material behind the stats; text follows the app theme. |
progress? | | | Fraction clamped to 0–1; omitted hides the track. NaN is treated as zero. |
progressBackground? | | | Optional material for the track, below the theme-colored fill. |
progressLabel? | | | Spoken name for the progress fraction. |
palette? | | | Override individual artwork and text swatches per period. |
celestial? | | | Draw the sun or moon. |
stars? | | | Draw deterministic stars during night. |
hills? | | | Draw both hill silhouettes. |
haze? | | | Draw the faint drifting haze; always hidden under Reduce Transparency. |
glow? | | | Draw the radial halo; always hidden under Reduce Transparency. |
animated? | | | Master motion switch. Each motion can also be switched independently. |
crossFade? | | | Fade sky layers when the period changes. |
animateCelestial? | | | Ease the sun/moon to its new position; reduced motion places it immediately. |
drift? | | | Slowly drift the haze while visible and foregrounded. |
motion? | | | Shared morph, layout and ambient character. |
children? | | | Replace the entire content block. Supply accessibilityLabel for custom content. |
accessibilityLabel? | | | Spoken summary. |
className? | | | Classes merged over the surface. |
style? | | | Native surface style. |
testID? | | | 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.
-
autouses 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.nowfixes 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.
childrenreplaces the entire default content block and needs a customaccessibilityLabel. -
Partial palettes override swatches per period. Check contrast for your artwork and text colours.
Sky and content settings
| Prop | Does | Default |
|---|---|---|
| value | Main formatted value | Required |
| period | Explicit sky or local-clock auto | auto |
| now | Fixed Date input for auto | Device clock |
| greeting | String or one greeting per period | Good morning / Good afternoon / Good evening |
| caption | Supporting copy | None |
| stats | Label/value pairs | Empty |
| statsBackground | Decorative stats material | None |
| progress | Clamped fraction; omitted hides the track | None |
| progressBackground | Decorative progress-track material | None |
| progressLabel | Spoken progress name | Progress |
| palette | Partial per-period swatches | Built-in palettes |
| celestial | Sun or moon disc | true |
| glow | Radial halo | true; suppressed by Reduce Transparency |
| stars | Stars at night | true |
| hills | Two wave silhouettes | true |
| haze | Faint haze | true; suppressed by Reduce Transparency |
| animated | Master animation switch | true |
| crossFade | Period cross-fades | true |
| animateCelestial | Body travel | true |
| drift | Ambient haze motion | true |
| motion | Morph, layout and ambient feel | App feel |
| children | Entire custom content block | Default summary layout |
| accessibilityLabel | Custom spoken summary | Composed content |
| className / style | Root styling | None |
| testID | Root and part identifiers | None |
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,layoutandambientmotion roles, so it follows your app's feel. Passmotionto 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 on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.