Skip to content

Component 027Controls

Day / Night Toggle

A cheerful sun slips behind the clouds as a sleepy moon brings stars, a nightcap, and a quiet indigo sky.

  • Next.js
  • Tailwind CSS
  • TypeScript
Click the switch or press Space to change modes.
Loading preview…
Live interactive preview

Quick start

Make it yours.

Save day-night-toggle.tsx in your components folder, then import it below. Use it in a Next.js project with Tailwind CSS.

TSXapp/page.tsx
import DayNightToggle from "@/components/ui/day-night-toggle";

export default function Example() {
  return <DayNightToggle />;
}

Behind the interaction

The details that make it work.

Designed to explore, ready to adapt.

A little daydream

A smiling sun, passing clouds, and a sleepy moon recreate the supplied interaction.

One switch, two moods

The stage changes from icy blue daylight to a glowing star-filled night.

Make it your theme switch

Use controlled or uncontrolled state and connect the change callback to your theme.

Keep exploring

View all components