Skip to content

Set visibility

Set visibility

The set visibility action allows you to show or hide the target element based on a condition.

For example, if we wanted to show a logout button if the user is logged in, our condition would look similar to this:

js
(c, f, i, n, r, v, e, t) => {
  return r.get_user.ok; 
};

Here, we are checking if the get_user request was successful. If it was, we are going to show the element. Otherwise, the element will be hidden.

How Set visibility works

The Set visibility action removes the element from the DOM if the condition evaluates to false.

When the condition evaluates to true, the element is added again to the DOM.

WARNING

If an element has the display property set to none, the element will never be visible, even when it's added back to the DOM.