Skip to main content
RapidDev - Software Development Agency
bubble-tutorial

How to add conditional statements in Bubble.io: Step-by-Step Guide

Master the three types of conditional statements in Bubble: element conditionals in the Conditional tab for visual changes, Only When conditions on workflow actions for execution control, and Do when condition is true for auto-triggered events. This covers the fundamentals of and/or logic, condition precedence, and common patterns.

What you'll learn

  • How to use the Conditional tab on elements for dynamic visual changes
  • How to add Only When conditions to workflow actions
  • How to use Do when condition is true for auto-triggered workflows
  • How to combine conditions with and/or logic
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner6 min read15-20 minAll Bubble plansMarch 2026RapidDev Engineering Team
TL;DR

Master the three types of conditional statements in Bubble: element conditionals in the Conditional tab for visual changes, Only When conditions on workflow actions for execution control, and Do when condition is true for auto-triggered events. This covers the fundamentals of and/or logic, condition precedence, and common patterns.

Overview: Conditional Statements in Bubble

This tutorial covers all three types of conditional logic in Bubble. Element conditionals change visual properties dynamically, Only When conditions control whether workflow actions execute, and Do when condition is true creates auto-triggered workflows. Understanding these three mechanisms is fundamental to building any dynamic Bubble app.

Prerequisites

  • A Bubble account with an existing app
  • At least one page with elements and workflows
  • Basic understanding of Bubble's Design and Workflow tabs
  • Familiarity with dynamic expressions

Step-by-step guide

1

Use element conditionals for visual changes

Select any element on the Design tab and click the Conditional tab in the Property Editor. Click Define another condition. Enter a When expression that returns yes/no (e.g., When Current User's role is Admin). Below it, select the property to change (background color, visibility, font, text, data source, etc.) and set the new value. You can add multiple conditions — they are evaluated top to bottom, with the bottom condition overriding conflicting properties from conditions above.

Pro tip: Use conditions on Groups rather than individual elements. Changing a Group's visibility hides all its children, which is more efficient than conditioning each element.

Expected result: Elements change their visual properties dynamically based on conditions you define.

2

Add Only When conditions to workflow actions

Go to the Workflow tab and click on any action within a workflow. At the bottom of the action's property panel, find the Only when field. Click it and build a yes/no expression. The action will only execute if this expression evaluates to yes. If it evaluates to no, the action is skipped but the workflow continues to the next action. This is different from workflow-level conditions which stop the entire workflow.

Expected result: Individual workflow actions are conditionally skipped based on Only When expressions.

3

Create auto-triggered workflows with Do when condition is true

Go to the Workflow tab and select the page events area. Click Click here to add an event and choose Do when condition is true. Define the condition expression (e.g., Custom State count > 5). Choose whether it should run Just once per page load or Every time the condition becomes true. Add actions that execute automatically when the condition is met. Be careful with Every time — frequent triggering can cause performance issues.

Expected result: A workflow triggers automatically whenever its condition expression becomes true.

4

Combine conditions with and/or logic

In any condition field, you can chain multiple checks with the and and or operators. For example: Current User's role is Admin and Current Page Thing's status is Active. This requires both conditions to be true. Use or for either/or logic: Current User's role is Admin or Current User's role is Manager. Bubble evaluates and before or by default. Use parentheses in complex expressions to control evaluation order.

Expected result: Complex conditions with multiple checks using and/or logic work correctly.

5

Understand condition precedence and best practices

Key rules: on elements, multiple conditions read top-down with the bottom one winning for conflicting properties. Workflow actions with Only When that are skipped still allow subsequent actions to run (but Result of step X will be empty). Do when condition is true fires client-side and will not run if the page is closed. Visibility precedence: Actions override Conditions override Default visible on page load. Never put sensitive data in hidden elements — tech-savvy users can still access it. For complex conditional logic architectures, consider working with RapidDev.

Expected result: You understand how Bubble evaluates conditions and can avoid common precedence mistakes.

Complete working example

Workflow summary
1CONDITIONAL STATEMENTS WORKFLOW SUMMARY
2==========================================
3
4TYPE 1: ELEMENT CONDITIONALS (Design tab Conditional tab)
5 Example: Button Submit
6 Condition 1: When Input Email's value is empty
7 This element isn't clickable: yes
8 Background color: gray
9 Condition 2: When Input Email's value is not empty
10 This element isn't clickable: no
11 Background color: blue
12 Precedence: bottom condition wins for conflicting properties
13
14TYPE 2: ONLY WHEN (Workflow actions)
15 Example: Submit workflow
16 Action 1: Create Order (no condition always runs)
17 Action 2: Send email
18 Only when: Checkbox Send Confirmation is checked
19 Action 3: Navigate to confirmation
20 (runs regardless of whether Action 2 ran)
21 Note: skipped actions return empty for Result of step X
22
23TYPE 3: DO WHEN CONDITION IS TRUE (Workflow events)
24 Example: Auto-save draft
25 Condition: Input Title's value is not empty
26 and Input Title's value has been changed
27 Run: Every time
28 Action: Make changes to Current Draft
29 title = Input Title's value
30 Warning: "Every time" can fire frequently add throttling
31
32COMBINING CONDITIONS:
33 AND: both must be true
34 Current User's role is Admin and Status is Active
35 OR: either can be true
36 User's role is Admin or User's role is Manager
37 Nested: use parentheses mentally
38 (Admin or Manager) and Status is Active
39
40PRECEDENCE RULES:
41 1. Workflow actions override element conditionals
42 2. Element conditionals override default properties
43 3. Bottom condition wins over top condition (same element)
44 4. Only When skips one action, not the whole workflow

Common mistakes when adding conditional statements in Bubble.io: Step-by-Step Guide

Why it's a problem: Putting sensitive data in elements hidden by conditionals

How to avoid: Use Privacy Rules on the data type to prevent the data from being sent to the browser at all.

Why it's a problem: Using Do when condition is true with Every time on a rapidly changing expression

How to avoid: Use Just once where possible, or add debouncing logic with a custom state and pause.

Why it's a problem: Expecting the workflow to stop when an Only When condition is false

How to avoid: To stop the entire workflow, put the condition at the workflow event level or use Terminate this workflow.

Best practices

  • Use element conditionals for visual changes and Only When for workflow logic
  • Apply conditions to Groups rather than individual elements for efficiency
  • Remember that bottom conditions win for conflicting properties on the same element
  • Use Privacy Rules instead of visibility conditions for security-sensitive data
  • Be cautious with Do when condition is true set to Every time
  • Put conditions at the workflow level when all actions share the same criteria
  • Test conditions with the Debugger to verify which path executes

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I am building a Bubble.io app and need to understand how conditional logic works. What are the three types of conditions, how do they differ, and what are the common gotchas with precedence and skipped actions?

Bubble Prompt

Add conditional logic to my app. Set up element conditionals for a submit button that changes color when the form is valid, add Only When conditions to a workflow that optionally sends an email, and create a Do when condition is true event that auto-saves draft content.

Frequently asked questions

Can I nest conditions (if/else if/else)?

Bubble does not have explicit if/else blocks. Use multiple conditions on the same element with specific When expressions. The bottom matching condition takes precedence, effectively creating an else-if chain.

Do conditions affect workload units?

The conditions themselves are free (client-side). However, if a condition expression includes a Do a search for, that search runs every time the condition is evaluated and consumes WUs.

Can I copy conditions between elements?

Not directly. You need to recreate conditions manually on each element. For repeated patterns, use Styles with built-in conditions or Reusable Elements.

How do I debug which condition is active?

Use the Debugger in Preview mode. Click on an element to see which conditions are evaluating to true and which properties are being overridden.

Can RapidDev help with complex conditional logic?

Yes. RapidDev specializes in Bubble development and can help architect complex conditional systems including role-based interfaces, multi-step form logic, and dynamic pricing rules.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.