How To Add Dark Mode Toggle to Your Website How To Add Dark Mode Toggle to Your Website | RaQMedia | Complexity Simplified

How To Add Dark Mode Toggle to Your Website

SHARE:

You May Also Like


How do I add a dark theme to my website?


What is Dark Mode / Night Mode?


As we all know, the use of mobile phones and laptop have become one of the most common routines in our life. Consequently, most of us use it obviously at night. Unfortunately, if you do so , you may have eyeache especially if you spend long hours in front of the screen at night.

Why Should You Add a Dark Mode Toggle


Having such a feature in your website - regardless of the platform you are using Blogger or WordPress - will add a bunch of advantages:

  1. A professional impression for your website.
  2. Better user experience.
  3. Increase the bounce rate as visitors will stay longer because they feel more comfortable reading your content.

How To Add Dark Mode Toggle to WordPress


The dark mode toggle has been introduced to WordPress few years ago. That's why there are several plugins that provides this option with just few click of installation. Raqmedia has reviewed the most popular ones. Here are the free plugins that we recommend:


How do I add a dark theme to my website?


This awesome feature is also introduced to the Blogger platform. You just need to make some adjustments by injecting some lines of code into your Blogger template. To do so, follow our four-step guide below.

Step 01

First, follow these steps to get your template ready:
  1. Login to you Blogger dashboard.
  2. Backup your template first.
  3. Head to Template then edit HTML.
  4. With Ctrl+C to copy and Ctrl+V to paste the following codes in their appropriate places.
  5.  Search for the line of code by hitting Ctrl+F
  6. Save your template and exit.;

Step 02


Next paste the following code just before </head>


[<style type='text/css'>
/* Night Mode By Raqmedia.com*/
.nightly{color:#999;font-size:13px}
.Switchbtn{position:fixed;text-align:center;display:inline-block;align-items:center;z-index:100;left:20px;top:20px}
.togglenight{display:none;}
.togglenight + .togglenight-btn{outline:0;display:inline-block;width:45px;height:10px;position:relative;cursor:pointer;margin-right:5px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}
.togglenight + .togglenight-btn:after,.togglenight + .togglenight-btn:before{position:relative;display:block;content:"";width:50%;height:100%}
.togglenight-switch + .togglenight-btn{background:#d5d2fc;border-radius:99em;transition:all .4s ease}
.togglenight-switch + .togglenight-btn:after{content:'';border-radius:100px;background:#887fff;transition:right 0.3s cubic-bezier(0.175,0.885,0.32,1.275),padding 0.3s ease,margin 0.3s ease;position:absolute;width:20px;height:20px;top:-5px;right:0;box-shadow:0 3px 6px rgba(0,0,0,0.16),0 3px 6px rgba(0,0,0,0.23)}
.togglenight-switch:checked + .togglenight-btn{background:rgba(255,255,255,.15)}
.togglenight:checked + .togglenight-btn:after{content:'';right:55%;background:#ff9f43}
.nightmode{background:#202124;color:rgba(255,255,255,.7)}
.nightmode a{color:rgba(255,255,255,.7)!important}
.nightmode a:hover{color:rgba(255,255,255,.4)!important}
.nightmode .class-baru{}
.nightmode .class-baru{}
</style>]

Step 03

Now, search ]]></b:skin> line and paste the following CSS code just above that ]]></b:skin>.
[.Switchbtn{position:fixed;text-align:center;display:inline-block;align-items:center;z-index:100;left:20px;top:20px}
.Switchbtn{top:10px;left:80px}}
@media screen and (max-width:480px){
.Switchbtn {left:50px}
.nightly{display:none}}
@media screen and (max-width:240px){
.Switchbtn{display:none}}]

Step 04


After that search for <body/> tag and PASTE the below code just before it.

[<div class='Switchbtn'>
<span class='nightly'>الوضع الليلي</span> <input class='togglenight togglenight-switch' id='nightmode' type='checkbox'/>
<label class='togglenight-btn' for='nightmode'/></div>
<script type='text/javascript'>
//<![CDATA[
// Night Mode
$("#nightmode").click(function(){$("body").toggleClass("nightmode")}),$("body").toggleClass(localStorage.toggled),$("#nightmode").click(function(){"nightmode"!=localStorage.toggled?($("body").toggleClass("nightmode",!0),localStorage.toggled="nightmode"):($("body").toggleClass("nightmode",!1),localStorage.toggled="")});
//]]>
</script>]

How to Add Blogger Widgets or Components into Dark Mode With CSS


After carrying the previous steps, you may notice that some parts of your template is not affected by the script and does not shift to Night mode. To fix this problem, you need to add these items or Class Ids using the following Css line. Just change .header with your new Class / item Id, you can also adjust the color to your favourite one.

[.nightmode .header{background:#222}]

Important Notice For Blogger Users

 Note: The Night Mode script may not work for all the blogger templates. Always backup your template before making any changes.
🔔 Subscribe to our channel to get exclusive & free tech tips & hacks 🔔

Eh! Voila! you have successfully added a stylish dark mode toggle to Blogger or WordPress. If you face any problems or find ways to improve this script or better WordPress Plugins, do share your thoughts and feedback.

We love to hear from you 😊💗.

COMMENTS

SHARE YOUR THOUGHTS
Name

Android,13,Android Apps,1,Apps,2,Around-The-World,14,Articles,11,Autos,4,Blogger,11,Blogging,26,Celebrities,9,Dictionaries,1,DIY,57,Earn-Money,10,English-Club,1,English-Exercises-Online,1,Entertainment,55,ESL-Games,1,Facebook,11,Freebies,1,Fun,21,Girls-stuff,41,Grammar,7,Health,35,Imaniat,66,Kids,44,Learn-Arabic,20,Learn-English,68,Lifestyle,138,Listening,1,Methodology,8,Motivation,9,Mysteries,14,News,32,Personality,1,Photoshop,8,Printables,25,Pronunciation,3,Puzzles,8,Qasas-ul-Anbiya,23,Qasas-ul-Quran,7,Quizzes,1,Rawae,18,Realities,17,Reviews,13,SEO,8,Services,3,Sira,24,Stories,1,Students-Corner,4,Teach-English,22,Teacher-Development,7,Tests,7,Tutorials,92,Vocabulary,40,Windows,4,Women,41,WordPress,4,Writing,1,YouTube,24,شروحات تقنية,16,
ltr
item
RaQMedia | Complexity Simplified: How To Add Dark Mode Toggle to Your Website
How To Add Dark Mode Toggle to Your Website
Add a free dark mode toggle to your website. Create a dark theme for your Blogger or WordPress website easily in few clicks. Follow Raqmedia guide and give your business blog a fancy look with a night mode widget.
https://1.bp.blogspot.com/-z5s3CrxL5p0/Xx8E3CXrPjI/AAAAAAAAI30/hFlTCsZ1NxwCv3oeq3yzcRZ-kbu0owvCACPcBGAYYCw/s320/how-to-add-dark-mode-to-website.webp
https://1.bp.blogspot.com/-z5s3CrxL5p0/Xx8E3CXrPjI/AAAAAAAAI30/hFlTCsZ1NxwCv3oeq3yzcRZ-kbu0owvCACPcBGAYYCw/s72-c/how-to-add-dark-mode-to-website.webp
RaQMedia | Complexity Simplified
https://www.raqmedia.com/2020/07/how-to-add-dark-mode-to-website.html
https://www.raqmedia.com/
https://www.raqmedia.com/
https://www.raqmedia.com/2020/07/how-to-add-dark-mode-to-website.html
true
5573019325017529632
UTF-8
Loaded All Posts No posts are found VIEW ALL Read more Reply Cancel reply Delete By Home PAGES POSTS View All You May Also Like - قد يعجبك أيضا LABEL ARCHIVE SEARCH ALL POSTS Sorry! No posts were found matching your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Click Here To Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Contents