Skip to content
Ballpoint

Ink Theme Toggle

Switches day and night: the new theme spreads from the button like a drop of ink, and the pen swaps sun for moon.

Only in Ballpoint

Night spreads from the button like a drop of ink.

Installation

pnpm dlx shadcn@latest add @ballpoint/ink-theme-toggle

Usage

tsx
import { InkThemeToggle } from "@/components/ui/ink-theme-toggle"

// On its own: toggles .dark on <html> and remembers it.
<InkThemeToggle />

// With next-themes:
const { resolvedTheme, setTheme } = useTheme()
<InkThemeToggle theme={resolvedTheme} onThemeChange={setTheme} />

Examples

Controlled

Own the theme (or hand it to next-themes) and the toggle only reports clicks.

Your state says light.

In a header

A ghost icon button at the end of a nav bar, where it usually lives.

Field notes

API reference

theme
"light" | "dark"

The current theme, when a theme library manages it.

onThemeChange
(theme: "light" | "dark") => void

Called with the new theme, inside the view transition, so the blot reveals it.

storageKey
default "theme"
string

Where the choice is kept in localStorage when the toggle manages the theme itself.

…
Button's

Any other Button prop (variant, size, seed).