# Guide: IF / ELSE logic

> Show, hide, and switch elements based on what users enter.

Source: https://bluepic.io/help/expressions-and-logic/guide-if-else-logic  
Language: en  
Category: expressions-and-logic  
Last updated: 2026-06-16

The `IF` function picks between two values based on a condition: `IF(condition, valueIfTrue, valueIfFalse)`. With it, parts of a design can respond to what users enter.

**Show or hide an element.** Connect an element's **Visibility** to a true/false value. With a [checkbox](https://bluepic.io/help/input-fields/checkbox-input-fields) whose variable is `showBadge`, just use `showBadge`: the element appears only when the box is ticked. The `IF` form ``IF(showBadge, true, false)`` does the same thing and is handy when the condition is more involved.

**Switch a value.** Change a colour based on a choice:

``IF(isDark, `#ffffff`, `#000000`)``

This sets text white on a dark theme and black otherwise.

![](https://imagedelivery.net/mudX-CmAqIANL8bxoNCToA/363d0ade-dd02-47eb-68f7-d34e4a07b400/max)

**Test a condition.** The condition can be a comparison like `price > 100`, or a check such as `IS_EMPTY_STRING(subtitle)` to hide a subtitle when it is left blank. For more than two outcomes, nest one `IF` inside another or use the `SWITCH` function.
