Nyxt has a brand new dark-mode!
Simple, just enable dark-mode
. That's it! Nyxt will do its best to attempt to configure the screen to be dark, while remaining legible and leaving images/videos unaltered.
If you want to selectively enable/disable dark-mode for different domains, you can leverage auto-mode to automatically/enable dark-mode. To find out more check out our article about auto-mode here.
If you want to change the behavior of dark-mode, you have a couple of options:
You can either:
You can source your styles from:
In order to do this you must make a style-association
struct and add it to your style-associations
list of your dark-mode
configuration.
Let's begin with our struct definition:
If you want to match based on a predicate, provide a predicate that accepts a single argument (the URL) and returns t or nil depending on whether the style should be applied.
style-association
struct, use the style
.style-file
with a full path to the file to load the style from.If you want to specify your style via a URL use a style-url
with a full path to the URL with the file to load the style from. Nyxt will download the style and cache it on your system (by default in ~/.local/share/nyxt/dark-mode-css-cache
).
Using this struct definition let's go through some examples:
In the example below if we visit "https://example.org", our style will be applied.
(make-style-association
:url "https://example.org"
:style (cl-css:css
'((body
:background-color "black"))))
In the example below if the length of the URL is greater than 10 characters, our style will be applied.
(make-style-association
:predicate (lambda (url) (> (length url) 10))
:style (cl-css:css
'((body
:background-color "black"))))
In the example below, our style will be sourced from a file.
In the example below, our style will be sourced from a URL.
style-association-list
When we've collected our list of style-association
objects, we will want to set our dark-mode
to use them. To do so we can do something like the following:
(define-configuration nyxt/style-mode::dark-mode
((nyxt/style-mode::style-associations
(list (nyxt/style-mode::make-style-association :url "https://nyxt.atlas.engineer"
:style (cl-css:css
'((body
:background-color "gray"))))))))
The above configuration will set the background color of https://nyxt.atlas.engineer to gray.
Here are some more examples of the default Nyxt dark-mode in action!
We hope you enjoy customizing dark-mode and viewing the Internet on your terms!
Thanks for reading :-)