Lazarus Dark Mode Tutorial (Windows)
Hey there, fellow developer! If you’re like me and spend hours coding away in Lazarus, you know that a bright white screen can be a bit much for the eyes. Today is a great day because I’m going to help you bring some stylish dark mode goodness to your Lazarus IDE and your own LCL applications on Windows!
Quick Note: This specific guide is just for my friends on Windows. If you’re on Linux or macOS, you’re in luck; your system theme usually handles this automatically!
Lazarus IDE Configuration
Before we dive in, let’s make sure we’re all set for success! It’s always a good idea to have the latest version of Lazarus installed. Make sure you’re using the right version for your computer (like the 64-bit version for 64-bit Windows) and that you’ve already flipped the “Dark Mode” switch in your Windows settings. A fresh install of Lazarus works best to keep things simple and smooth!
Installation Steps
- Fire up your Lazarus IDE.
- Head over to the metadarkstyle GitHub page and grab the
metadarkstylepackage. Just follow the friendly instructions there! - Once you’ve installed it, go ahead and rebuild the IDE. It only takes a moment!
Final Setup
Now for the fun part! Go to Tools > Options and look for Dark Style under Environment. Set the PreferredAppMode to Allow Dark, give the IDE a quick restart, and—voila!—you’ve got a beautiful dark workspace.
Application Implementation
You don’t have to keep all that style to yourself! You can easily add dark mode to the apps you build for others too.
- Open your project and make sure you’ve installed the packages mentioned above.
- Pop open Project > Project Inspector….
- Click Add > New Requirement.
- Search for and add both
metadarkstyleandmetadarkstyledsgn. - Now, open your main project file (the one ending in
.lpr). - In the
usessection, add these three friendly helpers:1 2 3 4 5
uses // ... uDarkStyleParams, uMetaDarkStyle, uDarkStyleSchemes;
- Right after the
beginstatement, add these two lines to tell your app to embrace the dark side:1 2
PreferredAppMode := pamAllowDark; uMetaDarkStyle.ApplyMetaDarkStyle(DefaultDark);
- Hit run and enjoy your sleek new creation!
I hope this guide helps you feel more comfortable while you’re building amazing things. Happy coding, and have a wonderful day!