- Bernard K
Dynamic zone visibility in Tableau (light mode vs dark mode switch)
Dynamic zone visibility released in Tableau 2022.3 allows you to hide and show objects (worksheets, layout containers etc.) in your dashboards based on a value of a field or parameter.
To use dynamic zone visibility, a field or a Parameter MUST be,
Independent of the viz, meaning the field returns a constant value independent of the structure of the viz, such as a fixed level of detail (LOD) calculation
The most common use case of the dynamic zone visibility is when users can show and hide zones in the dashboards based on their interaction with different marks. (e.g... by clicking on marks in a view).
In this article, I am going to demonstrate another use case, in which you can use the dynamic zone visibility to switch between light and dark themes in your dashboards.
Previously, you could configure the light and dark themes by simply creating two similar dashboards. One based on a dark theme while the other based on a light theme. Then use navigation buttons to allow users switch between the two dashboard themes.
This approach though seamless in application, doesn’t optimize well our dashboards as it requires you to duplicate each object across the two dashboard themes (you can imagine the complexity when you’ve a workbook with many tabs to replicate across the two themes).
Enters dynamic zone visibility…
New way – using dynamic zone visibility
With dynamic zone visibility released in Tableau 2022.3. Switching between light and dark themes in your Tableau dashboards is simplified.
Rather than duplicating views and objects across the two themes. All you need is to create a standard dashboard without the background color. Then use the zone visibility to control the dark and white layout containers configured as the dashboard background color - which in turn will adjust the theme of your dashboard based on the visible container.
To demonstrate this, I have created these two worksheets (and applied neutral colors – colors legible both in dark and light themes, as well as removed the background color of the worksheets)
Next, create a Boolean parameter – as shown below.
(So basically, when the selection on the parameter is TRUE, we’ll be showing the light mode of our dashboard).
Next, create a Boolean calculation, that will be used to show the dark mode (theme) of our dashboard as shown below.
(So, with this calculation – when the selection on the parameter (Mode) is False (alias Dark) this calculation will be returning TRUE, which will be applied to show the dark theme)
Let’s build the dashboard.
Float two containers which fit the entire dashboard view.
Change the background color of one of the containers to white and the other dark.
Float the worksheets on the dashboard area.
And make the parameter ‘Mode’ visible on the dashboard
Let’s control the visibility of the containers by first selecting the container with a white background color.
Check the box ‘Control visibility using value’
And select the parameter ‘Mode’
(So basically, when the selection on the parameter is TRUE (alias Light), the container with a white background color will be visible – which in turn will be applied as the background of the worksheets, creating a light theme).
Next, select the container with a dark background color.
Check the box ‘Control visibility using value’
And select the calculation ‘Dark mode’ we’ve created above.
(So basically, when the selection on the parameter is FALSE (alias Dark), the calculation ‘Dark mode’ will be returning TRUE – making the container with dark background visible – which in turn will be applied as the background of the worksheets, creating a dark theme).
The other way to configure the light and dark themes in your dashboards without duplicating dashboard tabs is as follows.
Float two containers that fill the entire dashboard area.
Fill the first container with light worksheets and objects (also change the background color to a light color).
Fill the other container with dark worksheets and objects (also change the background color to dark color).
Control both the containers using the Boolean parameter and calculation as demonstrated in the above case.
Next time you need to configure light and dark themes in your Tableau dashboards, try the above option which has been made possible by the dynamic zone visibility released in Tableau 2022.3.
I hope this article was helpful to you. If you wish to receive more Tableau tips and tricks, kindly join our mailing list by subscribing below.
If you like the work we do and would like to work with us, drop us an email on our contacts page and we’ll reach out!
Thank you for reading!