Inputs

Day Night Switch

A day/night theme switch: the track repaints from daylight sky to night, the sun turns into a crescent, and stars rise beside it.

  • switch
  • theme
  • dark-mode
  • animation

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/switch-009?lang=en

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "switch-009" (Day Night Switch) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/switch-009.json

Registry item: https://vibeui.ru/r/switch-009.json
Installs to: components/vibeui/switch-009.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A day/night theme switch: the track repaints from daylight sky to night, the sun turns into a crescent, and stars rise beside it.

A theme switch turning a sun into a crescent with rising stars, entirely in CSS. One file, zero dependencies, a server component.

## 3. How to use it
import { Switch009 } from "@/components/vibeui/switch-009"

<Switch009
  dayLabel="Light theme"
  nightLabel="Dark theme"
/>

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-switch-009-* palette — do not swap it for your theme tokens
- the crescent cut by a circle in the night-sky colour: change the track background and that circle must change with it
- the stars as a single dot with three shadows — decoration does not need three extra nodes
- the mode caption beside the thumb: a sun and moon glyph alone does not say what a tap will do
- the prefers-reduced-motion rule — the travel, the repaint and the rising stars must be switchable off
- the component's own light surface — without it the dark text disappears on a dark page

## 6. You may change
- the light mode caption through dayLabel
- the dark mode caption through nightLabel
- the focus accent colour through accent
- the sky and luminary colours in the day, night, sun and moon variables

## 7. Rules
- The component does not switch the site theme: it only reflects the choice, the state owner applies it.
- A real theme switch needs a third "follow system" mode — here there are deliberately two.
- The crescent cut depends on the night-sky colour: with a translucent background the crescent shows in daylight.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/switch-009.json
https://vibeui.ru/r/switch-009.json

Серверный компонент: всё состояние держит нативный checkbox с role="switch". Месяц сделан вырезом — круг цвета ночного неба на псевдоэлементе наезжает на солнце, днём он сдвинут за пределы бегунка. Звёзды нарисованы одной точкой с тремя тенями в box-shadow и проступают правилом input:checked ~ [data-part=stars]. Подпись режима переключается через :has(input:checked). Все переходы гасятся prefers-reduced-motion. Палитра в --vibeui-switch-009-*.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Switch009Props = Omit<
  ComponentPropsWithoutRef<"input">,
  "type" | "size"
> & {
  dayLabel?: string
  nightLabel?: string
  accent?: string
}

// Идея компонента: переключатель темы, а не абстрактный тумблер. Дорожка
// перекрашивается из дневного неба в ночное, бегунок из солнца превращается
// в месяц (вырез сделан вторым кругом с цветом фона), а звёзды проступают
// только ночью. Всё состояние держит нативный checkbox, JS не участвует.
const STYLES = `
:where([data-vibeui-block="switch-009"]){
--vibeui-switch-009-bg:oklch(1 0 0);
--vibeui-switch-009-fg:oklch(0.22 0.014 265);
--vibeui-switch-009-muted:oklch(0.55 0.014 265);
--vibeui-switch-009-border:oklch(0.91 0.006 265);
--vibeui-switch-009-day:oklch(0.82 0.11 230);
--vibeui-switch-009-night:oklch(0.32 0.06 275);
--vibeui-switch-009-sun:oklch(0.88 0.15 85);
--vibeui-switch-009-moon:oklch(0.95 0.02 265);
--vibeui-switch-009-accent:oklch(0.55 0.19 275);
--vibeui-switch-009-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="switch-009"]{
display:flex;align-items:center;justify-content:space-between;gap:1rem;
width:100%;max-width:17rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-switch-009-bg);
border:1px solid var(--vibeui-switch-009-border);border-radius:0.875rem;
font-family:var(--vibeui-switch-009-font);color:var(--vibeui-switch-009-fg);
font-size:0.875rem;cursor:pointer;
}
[data-vibeui-block="switch-009"] [data-part="caption"]{display:flex;flex-direction:column;gap:0.125rem}
[data-vibeui-block="switch-009"] [data-part="mode"]{font-weight:600}
[data-vibeui-block="switch-009"] [data-part="night-text"]{display:none}
[data-vibeui-block="switch-009"]:has(input:checked) [data-part="night-text"]{display:inline}
[data-vibeui-block="switch-009"]:has(input:checked) [data-part="day-text"]{display:none}
[data-vibeui-block="switch-009"] [data-part="hint"]{font-size:0.75rem;color:var(--vibeui-switch-009-muted)}
[data-vibeui-block="switch-009"] [data-part="track"]{position:relative;display:flex;flex:none}
[data-vibeui-block="switch-009"] input{
appearance:none;-webkit-appearance:none;margin:0;
width:3.75rem;height:2rem;border-radius:9999px;cursor:inherit;
background:var(--vibeui-switch-009-day);
box-shadow:inset 0 1px 3px oklch(0.2 0.02 265 / 25%);
transition:background-color .3s ease;
}
[data-vibeui-block="switch-009"] input:checked{background:var(--vibeui-switch-009-night)}
[data-vibeui-block="switch-009"] input:focus-visible{outline:2px solid var(--vibeui-switch-009-accent);outline-offset:2px}
[data-vibeui-block="switch-009"] [data-part="orb"]{
position:absolute;left:0.25rem;top:0.25rem;
width:1.5rem;height:1.5rem;border-radius:9999px;pointer-events:none;overflow:hidden;
background:var(--vibeui-switch-009-sun);
box-shadow:0 0 0.5rem oklch(0.88 0.15 85 / 70%);
transition:transform .3s cubic-bezier(.32,.72,0,1),background-color .3s ease,box-shadow .3s ease;
}
[data-vibeui-block="switch-009"] input:checked + [data-part="orb"]{
transform:translateX(1.75rem);
background:var(--vibeui-switch-009-moon);
box-shadow:0 0 0.5rem oklch(0.95 0.02 265 / 45%);
}
/* Месяц: круг цвета ночного неба наезжает на солнце и выедает из него серп.
   Днём этот круг сдвинут за пределы бегунка. */
[data-vibeui-block="switch-009"] [data-part="orb"]::after{
content:"";position:absolute;left:0.375rem;top:-0.25rem;
width:1.375rem;height:1.375rem;border-radius:9999px;
background:var(--vibeui-switch-009-night);
transform:translateX(1.5rem);
transition:transform .3s cubic-bezier(.32,.72,0,1);
}
[data-vibeui-block="switch-009"] input:checked + [data-part="orb"]::after{transform:translateX(0)}
/* Звёзды: три точки одной тенью, появляются вместе с ночью. */
[data-vibeui-block="switch-009"] [data-part="stars"]{
position:absolute;left:0.6875rem;top:0.625rem;
width:2px;height:2px;border-radius:9999px;pointer-events:none;
background:transparent;
box-shadow:0 0 0 0 transparent,0.5rem 0.375rem 0 0 transparent,1rem -0.25rem 0 0 transparent;
transition:box-shadow .3s ease;
}
[data-vibeui-block="switch-009"] input:checked ~ [data-part="stars"]{
box-shadow:0 0 0 1px oklch(1 0 0 / 85%),0.5rem 0.375rem 0 0.5px oklch(1 0 0 / 65%),1rem -0.25rem 0 0 oklch(1 0 0 / 50%);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="switch-009"] *{animation:none!important;transition:none!important}}
`

/**
 * Переключатель темы день/ночь: солнце превращается в месяц, всходят звёзды.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Switch009({
  dayLabel = "Светлая тема",
  nightLabel = "Тёмная тема",
  accent,
  className,
  style,
  ...props
}: Switch009Props) {
  const palette = {
    ...(accent ? { "--vibeui-switch-009-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-switch-009" precedence="medium">
        {STYLES}
      </style>
      <label
        data-vibeui-block="switch-009"
        className={className}
        style={palette}
      >
        <span data-part="caption">
          <span data-part="mode">
            <span data-part="day-text">{dayLabel}</span>
            <span data-part="night-text">{nightLabel}</span>
          </span>
          <span data-part="hint">Переключается вручную</span>
        </span>
        <span data-part="track">
          <input {...props} type="checkbox" role="switch" />
          <span data-part="orb" aria-hidden="true" />
          <span data-part="stars" aria-hidden="true" />
        </span>
      </label>
    </>
  )
}