Theme Toggle

A light/dark switch for next-themes that animates the whole page change with the View Transition API: wipe the new theme in as a rectangle from a corner, center or bottom, grow a sharp or blurred circle, or open it like window blinds.

Preview

Theme Toggle preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/theme-toggle
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

useThemeToggle

variant?
"circle" | "rectangle" | "circle-blur" | "blinds"
rectangle
start?
"center" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "bottom-up"
bottom-up

ThemeToggle

variant?
"circle" | "rectangle" | "circle-blur" | "blinds"

Animation variant. Default: "rectangle".

rectangle
start?
"center" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "bottom-up"

Origin direction for the reveal. Default: "bottom-up".

bottom-up
iconClassName?
string
—
className?
string
—

Updated