[how-to] Apply quick Dark mode to your app with Custom CSS

You can apply a Dark-mode to your app using custom CSS. To do this, within your app go to > Settings > CSS> apply body {filter:invert(1)}

Before:

After:

Interesting effect happens to me when I do this. See images below.

First one is a normal Text Input. The second is using the Dark Mode Theme. The last one uses filter:invert(1).

Not sure if this is a Windows only problem as your example, while not as crisp as the original text, is not as bad as I am getting, Retoolers seem to prefer Macs.

Yes, this works when in Edit mode as well - the entire Retool panel inverts, but yep fonts are a little fuzzy - on a Mac for me as well

Hi all,

I read this post and was thinking: Can I make this a toggle-able thing for the user?

I found a pretty basic solution (step 2 with the help of GPT). I did the following:

  1. Added a Number input component and set it to hidden (called inverter)
  2. Added a Switch Component, and assigned a basic JS script to it, which triggers on-toggle:
inverter.setValue(darkModeSwitch.value ? 1 : 0);
  1. Changed the App's Settings>Custom CSS to:
body {filter:invert({{ inverter.value }})

I know its not super-elegant, but it works. And its really more just for a bit of fun really.

Re the above comments, everything except for our logo looks fine in dark mode. Our org almost exclusively use Mac's for various reasons so the blurring mentioned is not an issue.

Here are some screenshots if you're interested (note the inverter component is hidden above the switch):

Light/Dark Screenshots and toggle

Light Mode:


Dark Mode:

Maybe someone will find this helpful, or have good suggestion for bypassing the need for the hidden number component?

Regards,
Nick

3 Likes

This was a great tip @nickaus. Thank you.

As a follow up, one could always restrict the filtering to just the "ContentWrapper" of the App to avoid changing the "Edit UI" of Retool, and messing up with the "inverted images" on an eventual avatar in the header.

1 Like

Interesting Idea. However, I would rather have the entire Dev environment in dark mode, but leave the app UX it's real colors.

After some head banging and finally some ChatGPT I came up with this:

body {
    filter: invert(1);
}

body .EditorPageLayout__quickPreviewWrapper {
    filter: invert(1);
}

That inverts the entire page, then inverts the EditorPageLayout__quickPreviewWrapper div which re-inverts (un-inverts?) the App canvas:

One caveat (@jessicasun): It does not work in Full Screen IDE mode. It seems as if the Custom CSS is only applied when the Canvas is visible so even the original body {filter:invert(1)} does not work in Full Screen mode.

2 Likes

Thanks for the call out, @bradlymathews! Will share this internally

@bradlymathews are you still seeing the issue in full screen mode? I'm not able to reproduce it anymore!

@Tess

The class name changed to EditorPageLayout and once I figured that out, then yes, it works in both modes.

I also realize I could have just added a second rule for the class the full screen mode used for the canvas.

just thought I'd mention the class name seems to have changed again?

body {
  filter: invert(1);
}

body .editor-canvas-container {
  filter: invert(1);
}

I see that most people are just inverting the colors for Dark Mode, but has anyone used this workaround to switch between two custom-made themes? We have two custom defined themes for a branded light and dark mode. So I wouldn't need to invert the colors, but rather switch between the two options for themes.

@Derek I've never used it before, but Dark Reader has a dev tool that lets you overwrite things on a per page/global basis

github and docs


+1 here. Let me know if you ever found anything!

img, .logo {
  filter: invert(1);
  transition: filter 0.3s ease;
}

adding this does not invert images, and adds a bit of smoother transition to the change

3 Likes

Hi i've just wanted to add something, following this thinking i did something to use dark mode only in the editor and don't affect the app even when it's published.

body {
  filter: invert(1); /*turns all black*/
}

body .editor-shortcuts-container {   /*returns app in editor to original*/
  filter: invert(1);
}

body .navbar.header-navbar { /*returns nav to original*/
  filter: invert(1);
}

body .presentation-container {  /*returns app in public link and runtime to original*/
  filter: invert(1);
}
2 Likes

You can now create and manage themes from your organization's Themes settings, or create custom themes that apply to individual apps. Organization-level themes are only available on Business and Enterprise plans. Custom themes are available on all plans.

1 Like