You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Richard Eckart de Castilho <re...@apache.org> on 2025/10/07 08:13:32 UTC
Dark mode in wicket applications with stylesheet switching
Hi all,
I am currently looking into updating the Kendo UI version in Wicketstuff.
For some Kendo styles (not for all), theres is a "normal" and a "dark" CSS file, e.g.
default-main.css
default-main-dark.css
Is there some best practice how to handle light/dark mode switching in Wicket apps
when it requires switching to an entirely different CSS stylesheet?
Kendo has the KendoUILibrarySettings, but those are global for the application, so
it doesn't make sense to have a light/dark switch there.
I had considered putting each of these CSS files into a separate Maven module, but
as the Wicket Kendo integration is written at the moment, only one style module can
be on the classpath at a time (because they have SPI Initializers that register the
respective stylesheet), so it seems reasonable to bundle the "normal" and "dark"
variations into the same module.
Cheers,
-- Richard
Relevant PR: https://github.com/wicketstuff/core/pull/1300
Re: Dark mode in wicket applications with stylesheet switching
Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Oct 7, 2025 at 11:13 AM Richard Eckart de Castilho <re...@apache.org>
wrote:
> Hi all,
>
> I am currently looking into updating the Kendo UI version in Wicketstuff.
>
> For some Kendo styles (not for all), theres is a "normal" and a "dark" CSS
> file, e.g.
>
> default-main.css
> default-main-dark.css
>
> Is there some best practice how to handle light/dark mode switching in
> Wicket apps
> when it requires switching to an entirely different CSS stylesheet?
>
> Kendo has the KendoUILibrarySettings, but those are global for the
> application, so
> it doesn't make sense to have a light/dark switch there.
>
> I had considered putting each of these CSS files into a separate Maven
> module, but
> as the Wicket Kendo integration is written at the moment, only one style
> module can
> be on the classpath at a time (because they have SPI Initializers that
> register the
> respective stylesheet), so it seems reasonable to bundle the "normal" and
> "dark"
> variations into the same module.
>
Both need to be on the classpath. so I guess this means the same module for
this case.
You could use the Session's style property to decide which scheme to
contribute. E.g. if there is a user session and its style is dark then
contribute the -dark.css, otherwise the default-main.css
Alternative: https://examples10x.wicket.apache.org/index.html uses the CSS
"color-scheme" property to detect the user's preference and adapt.
https://github.com/apache/wicket/blob/f0084f5caaef8d8d5c8ee71697d9092c876f92dd/wicket-examples/src/main/resources/org/apache/wicket/examples/style.css#L24
I am not sure whether this would work with default-main.css only. You can
try it.
> Cheers,
>
> -- Richard
>
> Relevant PR: https://github.com/wicketstuff/core/pull/1300
>
>