Skip to content

bug: Toggle does not work with React #3934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ricardomatias opened this issue Jun 2, 2025 · 2 comments
Open

bug: Toggle does not work with React #3934

ricardomatias opened this issue Jun 2, 2025 · 2 comments

Comments

@ricardomatias
Copy link

Reproduction URL (Required)

localhost

What version of daisyUI are you using?

5.0.43

Which browsers are you seeing the problem on?

No response

Describe your issue

No matter the value passed in to the checkbox, the first icon is always shown on page load.

import React from 'react';
import { useColorScheme } from '../hooks/useColorScheme';
import { Moon, Sun } from 'lucide-react';

export const DarkModeToggle = () => {
    const { colorScheme, toggleColorScheme } = useColorScheme();

    return (
        <label className="toggle text-base-content">
            <input type="checkbox" value={colorScheme} onChange={toggleColorScheme} className="theme-controller" />
            <Sun className="w-4 h-4" />
            <Moon className="w-4 h-4" />
        </label>
    );
};

This is either a bug or missing documentation.

Copy link

github-actions bot commented Jun 2, 2025

Thank you @ricardomatias for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.

@saadeghi
Copy link
Owner

saadeghi commented Jun 2, 2025

Please share a reproduction URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants