[OH3 widget] Hide widget component depending on a configured item

Motivation
Let’s say you have a widget that contains components that should be visible/invisible depending on if there’s an item configured for this component or not.
An example would be
An “all-purpose-light-widget” that shows a slider only if also a dimmer item is being configured.
(thanks @muelli1967 for his example [wiki] Building Pages in the OH3 UI: documentation draft (2/3) - #236 by muelli1967)

Light without dimmer item:
image

Light with dimmer item:
image

Solution
each component within a widget supports the configuration parameter “visible” that accepts true/false.
I couldn’t find a way to compare the item itels against “null”, but for an unconfigureed item, the state is “-”, so you can show/hide the slider with the following code. (Assuming you’ve configured the dimmer with props.dimmer in the widgets configuration)

 - component: oh-slider
            config:
              visible: =items[props.dimmer].state !== "-"
              item: =props.dimmer
              min: 0
              max: 100
              step: 1
              scale: true
10 Likes

It’s exactly what I’ve been looking for. Would be great if in a near future, this property be available in the widget’s UI configuration form. Thanks !