Theme Toggles
Switch between light and dark mode with an animated sun and moon toggle.
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/theme-togglesComplete the one-time setup first. Registry JSON lists source files and dependencies.
Usage
import { SunMoonMorphToggle } from "@/siteplane/components/theme-toggles";
<SunMoonMorphToggle />;Application theme
Pass your resolved theme to pressed (true for dark) and switch themes in onPressedChange; application-wide dark mode shows the complete provider. Both toggles show the sun in light mode and the moon in dark mode.
Sizes
size accepts sm, md, lg, and xl; without it, the toggle follows SiteplaneUIProvider.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
pressed / default | boolean | false | Controlled or initial state; true means dark mode and shows the moon. checked and defaultChecked are deprecated aliases. |
on | (pressed: boolean, eventDetails) => void | unset | Toggle’s pressed callback. onCheckedChange is a deprecated alias. |
size | sm | md | lg | xl | provider / lg | Control/icon size. |
aria-label | string | Dark mode | Accessible name. |
id | string | generated for SunMoon; unset for Layered | Button ID; SunMoon also derives an SVG mask ID. |
class | string | unset | Styles the outer span. |
disabled | boolean | false | Prevents interaction. |
SunMoonMorphToggleProps and LayeredThemeToggleProps extend Toggle props
without children or size. Both render a borderless, square icon toggle;
other native button attributes pass through. The shared ThemeToggleInputProps
type is internal.
Usage notes
Keep theme choice synchronized with your app provider, including portaled overlays. A pressed visual alone does not apply dark mode. Keep the accessible name constant; aria-pressed reports whether dark mode is on. Keyboard and reduced-motion behavior come from Toggle and the recipe styles.