Skip to content
Buttons

Mode Toggle

Animated sun ⇄ moon light/dark toggle icon-button.

Import

tsx
import { ModeToggle } from "@cronus-ui/ui";
bash
npx cronus-ui add mode-toggle

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component ModeToggleDefault layout:inline style:mode-toggle {
  aria-label:"Switch to dark mode"
  label "Switch to dark mode"
}

page "/audit/mode-toggle/default" type:custom {
  use ModeToggleDefault
}

API Reference

Generated from the component's exported types.

ModeToggleProps

Extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children">

Skip ModeToggleProps props table
PropTypeDefaultDescription
mode*
ModeToggleMode—The current color mode. The component is fully controlled — it never stores mode itself.
onModeChange*
(next: ModeToggleMode) => void—Called with the opposite mode when the button is activated (click, Enter or Space).
size
ModeToggleSize"md"Button footprint: `sm` (32px, 16px glyph) or `md` (36px, 20px glyph). Defaults to `md`.
type
string—Native type of the underlying element.
disabled
boolean—Disables pointer and keyboard interaction.
onClick
(event: MouseEvent) => void—Click handler.
className
string—Additional class names merged onto the root.