The traditional way of implementing dark mode in Bubble apps using conditional expressions is simple but has many downsides. This article will show how to implement a flexible and scalable mechanism for users to change the layout colors without plugins.
You can find many guides online on "how to add dark mode to Bubble apps." Most rely on the simple concept of adding conditional expressions to each element separately.
This approach is easy to implement but has several downsides that become apparent during app development.
You must add a conditional expression to change the color of an element based on user preferences for every single object in the app. This means dozens of additional hours for complex projects spent just on adding colors to the layout.
Although some conditional expressions can be implemented in global styles, the editor only allows the simplest conditions. For example, checking if the 'darkMode' field is 'yes' is possible, but conditioning based on 'Display' values from an 'Option Set' is not.
Conditional expressions on elements are triggered quite late during the app's code loading. With many operations happening earlier (e.g., during the 'Page is loaded' event), there will be a noticeable moment when the color of an element changes from the default to the conditional expression's specified color.
If you use advanced design systems (like Material), the limit of 32 color variables will be too small to handle the primary color palette, not to mention an additional dark mode. As a result, you will end up using literals, which are hard-coded color values. This approach is prone to errors and typos, needs to be more scalable, and unnecessarily increases the code volume of the app.
The target group for one of the apps I built includes professional developers. I wanted the user experience to be as close as possible to the UX/UI patterns known from the most popular programming tools, with one of the features being the ability for users to choose the interface's color palette.
If I use the traditional approach described above, adding a new color scheme to the app would require me to add new conditional expressions to each object separately. Instead of the traditional approach, I used a simple trick – dynamically changing the color variable values (CSS custom properties/color variables) based on user preferences.
This method has several advantages:
Freight digitization with no-code streamlines processes, cuts costs, and improves customer service. Discover how to implement it efficiently.
How to Automate Logistics Processes and Improve Customer Service in a Freight Company?Artificial intelligence revolutionizes transportation by optimizing routes, reducing costs, and automating fleet management. Discover how AI enhances logistics efficiency and transforms the industry.
Artificial Intelligence in Transport: How AI Optimizes Routes and Reduces Costs?AI and no-code technologies revolutionize accounting by automating invoices, financial analysis, and payment reminders, reducing costs. Discover how automation enhances financial management.
AI and No-Code Low-Code in Automated Accounting: How to Eliminate Manual Data EntryLooking for insightful articles about no-code and low-code technologies? Discover the latest on no-code and low-code development on our blog! Learn how to create software, set up websites, and build mobile apps without coding knowledge using low-code and no-code solutions.
Explore expert articles that introduce you to the best no-code platforms and top low-code development platforms, including Bubble, Webflow, Flutter Flow, Xano, and many more development tools. Whether you're learning the basics or diving into advanced techniques, become a skilled no-code developer or citizen developer with our guidance.
Our No Code Low Code Blog will immerse you in a world of innovative technologies where software creation is easy and enjoyable. Increase your productivity and improve your business processes with no-code and low-code platforms. If your goal is to develop an app, build an MVP, or establish a website with no-code/low-code technology, you've come to the right place! Gain both technical and business knowledge now with havenocode, your ultimate no-code and low-code resource!