Hi, I'm wondering is there a way to provide LocalC...
# compose-desktop
Hi, I'm wondering is there a way to provide LocalConfiguration in Compose for Desktop. If that exists for desktop, which dependency is that part of? 🙂
Given that it returns a
, I assume accessing
can only be done on a platform that defines
, which is Android-only.
Ah that makes sense. Thanks for the answere! 😊🙏 Do u know if there is any other way to force dark mode on a section of compose code in compose desktop? 😊 if that even makes sense on desktop 🤔
There’s no way to force the OS you’re running on to enable Dark Mode (since it’s a per-platform feature), but you can query it via
(which delegates to checking via skiko as seen here: https://github.com/search?q=repo%3AJetBrains%2Fskiko+%22actual+val+currentSystemTheme%22&type=code) If you want to “force” dark mode, you can just replace any usages of that API with a constant
and use a MaterialTheme with values for dark mode.
If you don’t already have a dark material theme, you can generate one here
Okay, that makes sense! Thanks for great answer! 🙂 I think I'll try to replace the usage of the
But I think if I do that, I will do it for the whole system and not just one section 🤔
You can apply it to just a particular scope of your app. If you have a method to apply your theme like so:
Copy code
fun MyTheme(isDarkMode: Boolean = isSystemInDarkTheme()) {
  if (isDarkMode) {
    MaterialTheme(colors = /* dark colors */)
  } else {
    MaterialTheme(colors = /* light colors */)
you can force only a specific part of the app to be in dark mode, if you want:
Copy code
MyTheme {
  // This is in either light mode or dark mode, depending on the platform
  Box {

    MyTheme(isDarkMode = true) {
      // This part will always be in dark mode