Skip to content
caliper ui docs

Pro

Sun path

A day's sun drawn on its arc, with a slider to move through the day. The sky changes colour with the sun's height, and after sunset a moon takes the same arc as stars come out.

Pro
pnpm dlx shadcn@latest add @caliper/sun-path

Midsummer in Lisbon

Drag the slider, or jump to a time.

06:1214h 45m of daylight20:57

Sun is up

12:30

Installs components/ui/sun-path.tsxDepends on lucide-reactMotion honours reduced motion

When to use

Use it for

  • Weather, travel, photography and solar-energy pages.
  • Anywhere the time of day shapes a decision.

Skip it when

  • Exact positions in the sky; it is an illustration of the day's shape.
  • Polar days and nights with no sunrise.

Decisions

Why it is built this way, so you know what to keep when you change your copy.

Behaviour

Jumps glide
Dawn, Noon, Dusk and Midnight move the sun there over about a second; dragging the slider is direct.

Styling

Blended in OKLab
The sky is mixed between night, twilight and day in a perceptual colour space, so the middle is never muddy.

Usage

Times as text
Sunrise, sunset and daylight length are written out, and the slider reads its time aloud.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/sun-path

Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source. It is built from SunPath, bodyAt, toMinutes and formatClock.

example.tsx
import { SunPath, bodyAt, toMinutes, formatClock } from "@/components/ui/sun-path"

The worked example comes with Pro

The 23-line example behind the preview opens here, ready to copy.

  • 626 Pro parts, blocks and page templates, all with source
  • $149 once, with lifetime updates. No renewal
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

SunPath

component

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
sunrise *string—Local sunrise and sunset as "HH:MM".
sunset *string—
defaultTimestring"12:00"Where the slider starts, as "HH:MM".
onTimeChange((minutes: number) => void)—

bodyAt

component

No props of its own; it accepts the native props of its root element.

toMinutes

component

No props of its own; it accepts the native props of its root element.

formatClock

component

No props of its own; it accepts the native props of its root element.

Accessibility

It exposes group semantics, with aria-hidden, aria-label and aria-valuetext kept in step with state.

No custom key handling; Tab and the native activation keys do the work.

Motion

It checks prefers-reduced-motion itself and settles immediately instead of travelling. Every state is still reachable.

All Media examples