search

Home  >  Q&A  >  body text

How to use CDN to add dark mode switching in Tailwind CSS

<p>I am new to JavaScript. Recently I started using Tailwind CSS. Now I want to add it to my blog template. But I don't know how to add a dark mode toggle button in Tailwind Css. How should I add a dark mode toggle button in Tailwind Css. </p> <p>Note: Since I am using a blogging platform, I cannot add from the native library. Therefore I use CDN. </p> <pre class="brush:php;toolbar:false;"><link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.15/dist/tailwind.min.css" rel="stylesheet"></pre> <p>Do I need another CDN? Or JavaScript code? </p>
P粉817354783P粉817354783460 days ago564

reply all(1)I'll reply

  • P粉940538947

    P粉9405389472023-08-30 13:47:02

    Please check the code link below, I hope it is useful to you. We used a library from Tailwind called flowbite which provides a built-in dark mode toggle so we could apply it.

    Please refer to this link: https://codesandbox.io/embed/fervent-fast-6v9fn5?autoresize=1&fontsize=14&hidenavigation=1&theme=dark

    You can also refer to this document: https://flowbite.com/docs/customize/dark-mode/

    reply
    0
  • Cancelreply