Skip to content

Day/Night Indicator

A copy-paste watch faces & clocks component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Watch Faces & ClocksHTMLCSSany framework

Copy into your project

HTML
<div class="nuda-dn" role="img" aria-label="Day-night indicator">
  <div class="nuda-dn__sky">
    <div class="nuda-dn__star" style="left:15%; top:20%"></div>
    <div class="nuda-dn__star" style="left:45%; top:35%"></div>
    <div class="nuda-dn__star" style="left:75%; top:15%"></div>
    <div class="nuda-dn__star" style="left:85%; top:40%"></div>
    <div class="nuda-dn__orb"></div>
    <div class="nuda-dn__horizon"></div>
    <div class="nuda-dn__land"></div>
  </div>
  <div class="nuda-dn__time">
    <span>21:42</span>
    <em>Night</em>
  </div>
</div>
CSS
/* Day/Night Indicator
   Animated night scene with floating moon and twinkling stars.
   Swap orb gradient + sky gradient for a daytime variant. */

.nuda-dn {
  --ink: #fafafa;
  display: inline-block;
  width: 220px;
  border-radius: 14px;
  overflow: hidden;
  background: #0c0c10;
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: system-ui;
  color: var(--ink);
}

.nuda-dn__sky {
  position: relative;
  height: 110px;
  background: linear-gradient(180deg, #0a0a1a 0%, #16162a 50%, #1a1a30 100%);
}

.nuda-dn__star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fafafa;
  border-radius: 50%;
  box-shadow: 0 0 4px #fafafa;
  animation: nuda-dn-twinkle 3s ease-in-out infinite;
}
.nuda-dn__star:nth-child(2) { animation-delay: 0.4s; }
.nuda-dn__star:nth-child(3) { animation-delay: 0.8s; }
.nuda-dn__star:nth-child(4) { animation-delay: 1.2s; }

.nuda-dn__orb {
  position: absolute;
  right: 30px;
  top: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 60% 35%,
    #fafafa 0,
    #a0a0a8 70%,
    #63636e 100%
  );
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.2);
  animation: nuda-dn-float 6s ease-in-out infinite;
}

.nuda-dn__horizon {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
}

.nuda-dn__land {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24px;
  background: linear-gradient(180deg, #1a1a20, #09090b);
}

.nuda-dn__time {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px;
}

.nuda-dn__time span {
  font: 600 18px ui-monospace, Menlo, monospace;
}

.nuda-dn__time em {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 2px;
  color: #a0a0a8;
}

@keyframes nuda-dn-twinkle {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

@keyframes nuda-dn-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .nuda-dn__star,
  .nuda-dn__orb { animation: none; }
}

How to use Day/Night Indicator

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More watch faces & clocks components

← Browse all NudaUI components