[wp-trac] [WordPress Trac] #51656: add_theme_support() for 'wp-dark-theme' so plugins can use consistent CSS for dark themes

WordPress Trac noreply at wordpress.org
Wed Oct 28 14:57:28 UTC 2020


#51656: add_theme_support() for 'wp-dark-theme' so plugins can use consistent CSS
for dark themes
-------------------------+-----------------------------
 Reporter:  mpol         |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Themes       |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 As a plugin developer I sometimes have to write CSS for the frontend for
 one of my plugins. When I do need to do that, I try to write CSS that fits
 most themes, like light-grey colors. When a website has a theme with dark
 colors activated, these light colors do not fit it and it can give a bit
 of a jarring experience, that deteriorates the idea of that dark theme.
 I will attach a screenshot with the dark theme 'minimal-dark' and the
 plugin 'gwolle-gb'. You can see a black frontend page and a box from the
 plugin with light colors.

 I think it would be good if there is a body-class for themes to use where
 they can declare that they are a theme with dark colors. Plugins can then
 provide some dark-theme CSS for elements. When themes and plugins all use
 the same consistent body-class it can be a useful feature.

 Please be aware that this is a different ticket than #50051 which is much
 wider in scope, where the setting of the browser (or desktop) will make
 themes switch to a dark mode.
 This one is about a body-class that would be a way for theme developers to
 communicate to plugin developers that it is a dark theme and needs dark-
 colored CSS.
 Also, this is not about form elements like buttons. I strongly believe
 styling of form elements is up to the theme.

 I am willing to provide a patch.
 I can imagine adding support for it in 'get_body_class()' and a comment
 update in 'add_theme_support()' would be enough. I tested this already.
 I propose 'dark-theme' as parameter, where the 'wp-dark-theme' gets added
 as a body-class, just to avoid conflict with third-party solutions. Also
 to make clear this is not about a dark-mode for browsers.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51656>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list