Dark/Light simple animation toggle issue
Unanswered
Giant panda posted this in #help-forum
Giant pandaOP
Hello
Greetings ,
I am facing a simple animation toggle issue with
Issue is that, it is instant but not animated with duration. When i took certain code from original to simple one to test if it works and it is working.
Greetings ,
I am facing a simple animation toggle issue with
rotation issue with icon sun and moon from Lucide React,Issue is that, it is instant but not animated with duration. When i took certain code from original to simple one to test if it works and it is working.
"use client";
import { useState } from "react";
import { Moon, Sun } from "lucide-react";
export default function ButtonRotationTest() {
const [isDark, setIsDark] = useState(false);
return (
<div className="p-8">
<button
onClick={() => setIsDark(!isDark)}
className="mb-8 px-4 py-2 bg-blue-500 text-white rounded"
>
Toggle Dark Mode
</button>
<div className={`relative p-4 rounded-lg ${isDark ? 'dark' : ''}`}>
<button
className="inline-flex items-center justify-center w-10 h-10 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800"
title={isDark ? "Switch to light mode" : "Switch to dark mode"}
>
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 duration-1000" />
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 duration-1000" />
</button>
</div>
<p className="mt-4">{isDark.toString()}</p>
</div>
);
}28 Replies
can you post the video of what it looks like?
have you tried to reproduce the issue using simple elements instead of using <Sun> ?
Giant pandaOP
I want to show a record , with both simple and original one to show
this is simple one
have you tried to reproduce the issue using simple elements instead of using <Sun> ?
change <Sun className="..."> with <p className="...">T</p>
can you reproduce the issue on a minimal reproducible repository?
@aardani did you use <Button> or <button>? please be consistent. its hard to tell what your code is like
Giant pandaOP
i am using Button from shadcn
I shall try to be consistent.
Ooof , i did mistake , for Simple one i did use
button instead of shadcn Buttonyeah thats why im confused :(
so we now know, <button> works but not <Button> 

what is inside <Button> ?
@aardani so we now know, <button> works but not <Button> <:ChocoHmm:932251629212794950>
Giant pandaOP
Button also works on simple one , just tested
nice observation!
Giant pandaOP
I am trying hard to find what am i doing wrong , i am thinking to wrap it with more
divmaybe its the parent/wrapper component thats causing the issue
you can also try to reproduce the bug in another repo and share it so people can debug it
Giant pandaOP
where can i upload ? in my git ?
@aardani you can also try to reproduce the bug in another repo and share it so people can debug it
Giant pandaOP
Sorry , forgive me , i don't understand. I am happy to share.
i will create git then
@Giant panda where can i upload ? in my git ?
github repo yeah
minimum reproducible repository means keeping the bug but remove unecessary code that doesn't cause the bug
Giant pandaOP
yeah , i will give there one navigation page
including simple one that works
I made it minimal as possible