Theme Toggle
Theme Toggle coordinates theme presentation and a transition treatment.
Practical React example
Switch the page’s existing light and dark theme with an optional reveal effect.
Before you copy and paste
Keep the example in the React rendering environment required by the imported component. Copy components/motion/theme-toggle.tsx and its returned support files from the Code tab; preserve the project-relative paths.
Listed package dependencies: clsx, lucide-react, motion, next-themes, react, tailwind-merge.
Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.
Switch the page’s existing light and dark theme with an optional reveal effect
// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
"use client";
import { ThemeToggle, type ThemeVariant } from "@/components/motion/theme-toggle";
const VARIANTS: { variant: ThemeVariant; label: string }[] = [
{ variant: "rectangle", label: "Rectangle" },
{ variant: "circle", label: "Circle" },
{ variant: "circle-blur", label: "Circle blur" },
{ variant: "blinds", label: "Blinds" },
];
export function ThemeTogglePreview() {
return (
<div className="flex h-full w-full items-center justify-center gap-5">
{VARIANTS.map(({ variant, label }) => (
<div key={variant} className="flex flex-col items-center gap-2">
<ThemeToggle
variant={variant}
start="bottom-up"
className="rounded-xl border border-border bg-background p-2.5"
iconClassName="h-5 w-5"
/>
<span className="text-[11px] text-muted-foreground">{label}</span>
</div>
))}
</div>
);
}
Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.
Integrate the control with the theme class and tokens used by your application. Check the initial theme before hydration to avoid a flash of the wrong palette.
Customization
- ThemeToggleProps.variant
- Optional; ThemeVariant. Animation variant. Default: "rectangle".
- ThemeToggleProps.start
- Optional; RectStart. Origin direction for the reveal. Default: "bottom-up".
- ThemeToggleProps.iconClassName
- Optional; string.
- ActionSwapButtonProps.items
- Required; ActionSwapItem[].
- ActionSwapButtonProps.value
- Optional; string.
- ActionSwapButtonProps.defaultValue
- Optional; string.
- ActionSwapButtonProps.onValueChange
- Optional; (value: string, item: ActionSwapItem) => void.
- ActionSwapButtonProps.variant
- Optional; ActionSwapButtonVariant.
- ActionSwapButtonProps.size
- Optional; ActionSwapButtonSize.
- ActionSwapButtonProps.animation
- Optional; ActionSwapAnimation.
- ActionSwapButtonProps.iconOnly
- Optional; boolean.
- ActionSwapButtonProps.cycle
- Optional; boolean.
- ActionSwapTextProps.value
- Required; string.
- ActionSwapTextProps.children
- Required; ReactNode.
Integration notes
- The animation depends on browser capabilities; a usable instant theme change should remain available.
- Verify focus styling, reduced motion and persisted preference behavior separately from the reveal.
Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.
Give your agent taste.
The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.
All components are free. Sign up only to connect MCP.