Changing visibility based on device width. Like Media Queries in CSS

The logic is running only when changing the parent data model (AppData/PageData/SomeDataContainerData), in your case you need to use App Extensions, take a look at this topic

Regards, Vlad