A theme button on a website?

  • 0
    How to implement a button on the site that, when clicked, you can change the site theme from dark to white.
    A detailed description is possible
    JavaScript Benjamin Wright, Aug 21, 2020

  • 3 Answers
  • 0
    the easiest way is filter: invert (& lt; value & gt;);

    Well, in general here many examples
    Anonymous

  • 0
    1.tag html add the parameter data-theme

    2. in styles, set colors through variables in : root

    :root[data-theme="mytheme"] {
    --color-primary: $fff;
    --color-secondary: $000;
    --color-accent: $0f0;
    ...
    }


    3. Change the value for data-theme via JS
    Anonymous

  • 0
    You have 2 color schemes in different files.

    white.css

    black.css

    main.css



    White.css is loaded by default

    The user clicks a button, js sets a checkbox in cookies or locastoredzh that it is necessary to load black.css and either on the fly or on reboot another theme is loaded (via link in the markup head)
    Harper Harper

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!