Skip to content

No.89 · Controls

Eclipse Toggle

A day/night switch drawn as a tiny sky: the sun sinks behind the hills as the moon rises, clouds drift out and the stars come on.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Paper

Build a dark-mode switch (a <button role="switch" aria-checked>, 96×44px, or 132×60 large) drawn as a small landscape, in CSS only. The track is a sky: a blue gradient (#5fb2ff → #bfe3ff) with an inset shadow, with a night gradient (#070d24 → #22305c) layered over it whose opacity crossfades over 700ms. A curved hill sits along the bottom and darkens at night. The sun is a 34px disc (warm radial gradient, a soft glow ring) at the left. Switching to night it moves right and down behind the hills — a translate of 42% of the width across and 90% of the height down on one cubic-bezier(0.65,0,0.35,1), so it reads as setting along an arc — and fades. At the same time the moon (a pale disc with two crater spots and a shaded edge) rises from behind the hills on the right along the mirrored path. Two clouds (pill shapes with a puff) drift out to the right and fade; seven 2px stars fade in and twinkle on staggered 2.4s loops. Switching back reverses everything. Pressing dips the sky to 97%. Focus shows a ring in sun or moon colour. Controlled or uncontrolled; reduced motion makes every change instant. Selected variant — Paper (paper): Apply the paper theme. Where the brief above gives no colour values for it, choose a restrained paper palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Click, tap, Space or Enter flips between day and night. Motion: Sun and moon travel 700ms cubic-bezier(0.65,0,0.35,1); sky crossfade 700ms; stars fade in after 200ms and twinkle every 2.4s. Accessibility: A real switch: role="switch", aria-checked and a label ("Dark mode"); everything inside is decorative and aria-hidden. Reduced motion removes the travel and twinkle. Responsive behavior: Two sizes; everything inside is sized from CSS variables, so it scales cleanly. Touch: Works the same on touch; the press dip gives tap feedback. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Click, tap, Space or Enter flips between day and night.
Motion
Sun and moon travel 700ms cubic-bezier(0.65,0,0.35,1); sky crossfade 700ms; stars fade in after 200ms and twinkle every 2.4s.
Accessibility
A real switch: role="switch", aria-checked and a label ("Dark mode"); everything inside is decorative and aria-hidden. Reduced motion removes the travel and twinkle.
Responsive
Two sizes; everything inside is sized from CSS variables, so it scales cleanly.
On touch
Works the same on touch; the press dip gives tap feedback.