Configuration
WordPress Themes
Auto Detection
By default, FastComments will auto-detect if your site has a dark background based on the "distance from black" in the color circle.
Our products try to do their best at this, however there are almost infinite colors in the color wheel, and there may be scenarios where the application chooses to use dark mode when it is not appropriate, and vice-versa. This documentation covers how to have more fine-grained control over this.
Technical Details
We detect dark mode by traversing the elements in the page up from the comment widget, looking for a dark background when the widget initially loads.
To toggle dark mode after this step, you must call the widget to update its configuration. This is covered in the Manual Configuration
section.
Manual Configuration
For Developers - Forcing Dark Mode Off
Forcing dark mode off can be done by passing hasDarkBackground
as false
in the widget configuration. This works for the VanillaJS, Angular, React, Vue, and React Native libraries.
Each library has an examples
folder on GitHub that contains examples on how to use dark mode.
Forcing Dark Mode On
We can force dark mode to always be on by setting hasDarkBackground
to true
.
We can also do this via the Widget Customization UI here.
Under Base Theme
simply select Force Dark Mode
.
VanillaJS Widget - Updating Dark Mode
The easiest way to update dark mode is to go through all instances of the widget on the page, and update their configuration:
WordPress Networker Theme Dark Mode Support
For the WordPress Networker theme, we have to add custom code to our WordPress installation to auto-detect dark mode and update the comment widget.
The code must be inserted into the footer of your site. There are quite a few plugins which can do this, so we won't list them here. However, here is the code to add: