RFR: 8342705: Add dark mode for docs

Hannes Wallnöfer hannesw at openjdk.org
Wed Jul 16 09:54:50 UTC 2025


On Tue, 15 Jul 2025 15:20:15 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> Please review an enhancement to add a dark theme to javadoc-generated API documentation. There is a new button in the top right corner that brings up a menu to switch between themes. Available options are "Light", "Dark", and "System Setting" (following the system-wide theme setting). The selected theme is stored and preserved across browser sessions.
>> 
>> Generated docs [can be viewed here](https://cr.openjdk.org/~hannesw/8342705/api.02/) (`java.base` module only). The docs were generated with syntax highlighting enabled in order to view the highlighting themes, although that is obviously not part of the change.
>
> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/highlight.css line 71:
> 
>> 69:     .hljs-title.function_,
>> 70:     .hljs-template-variable {
>> 71:         color: #66bcce;
> 
> I don't think you can nest rules here, the browser may skip/ignore them.

It [works for me](https://cr.openjdk.org/~hannesw/8342705/api.02/java.base/java/lang/Thread.html#creating-and-starting-threads-heading), I've tried it on Firefox, Safari and Chrome. 

Documentation of CSS nesting: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting/Using_CSS_nesting
It's implemented in all major browsers: https://caniuse.com/?search=css%20nesting

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26185#discussion_r2209846566


More information about the javadoc-dev mailing list