uibrik

Theme Switch

Preview

Customize

Circle
Reveal duration0.50s
Auto
Size40px
Radius12px

Usage

import { ThemeSwitch } from "@/components/uibrik/theme-switch/theme-switch";

<ThemeSwitch />

Installation

npx shadcn@latest add https://uibrik.com/r/theme-switch.json
Adds the files to components/uibrik/theme-switch and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/theme-switch.

Props

ThemeSwitch
reveal
Type "circle" | "expand" | "split" | "wipe" | "diagonal" | "blinds" | "blur" | "zoom" | "none"
"circle"
How the new theme takes over the page.
revealDuration
Type number
0.5
How long the reveal takes.
easing
Type "auto" | "out" | "in-out" | "linear"
"auto"
Auto uses each mode's own curve: ease-out for reveals from a point, ease-in-out for sweeps.
wipeFrom
Type "left" | "right" | "top" | "bottom"
"left"
Which edge of the page the wipe starts from.
corner
Type "top-left" | "top-right" | "bottom-left" | "bottom-right"
"top-left"
Which corner the diagonal sweeps in from.
orientation
Type "horizontal" | "vertical"
"horizontal"
Split: a band opening up and down, or sideways. Blinds: rows or columns.
slats
Type number
8
How many slats the blinds have.
cascade
Type number
0
0 opens every slat together; higher opens them one after another.
blurAmount
Type number
8
How far the pages blur.
depth
Type number
0.04
How far the pages scale (0.04 is 4%).
size
Type number
40
Width and height.
radius
Type number
12
Corner radius.
theme
Type "light" | "dark"
–
Controlled theme. Leave unset and the button follows the page's own theme (the dark class on <html>).
onChange
Type (theme: "light" | "dark") => void
–
Called with the theme being switched to.
setTheme
Type (theme: "light" | "dark", origin: { x: number; y: number }) => void
–
Applies the theme in place of the built-in page switch, e.g. a theme provider's setter. Gets the button's centre.
storageKey
Type string
"theme"
localStorage key the choice is saved under.
className
Type string
–
Classes for the button.