> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional styling

> Dynamically update styling and properties of UI elements based on conditions, reducing the need for multiple prototypes.

Conditional styling enables dynamic, data-driven design adjustments based on specific conditions. It helps reduce the need for multiple prototypes by applying styles conditionally, depending on the data and platform-specific configurations.

> [!NOTE]
>
> **Conflict resolution:** Conditions apply cumulatively. Every condition that evaluates to true applies its overrides, and when two of them set the same property, the latest one (lowest in the list) takes priority.

***

## Configuring conditional styling

1. Open the **UI Designer**.
2. Select an element that supports conditional styling (see [Availability](#availability)).
3. Navigate to the **Styles** tab.
4. Locate the **Conditional styling** section.
5. Click **Add new** (**+**) in the section header to add an expression. Expressions are numbered **Expression 1**, **Expression 2**, and so on.
6. Write the condition in the expression's inline editor, or click **Open in editor** next to the expression name to open it in the expression editor, where you can run it against test data.
7. Click **Add effect** (**+**) next to **Effects** and pick the property to override, then set its value.

***

## Conditional styling properties

![](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/4.6/image%20%2812%29.png)

### Availability

Conditional styling is available on these components:

| Component |
| - |
| Text |
| Link |
| Container |
| Card |
| Form |
| Collection |
| Collection prototype |
| Image |

### Properties you can override

The properties available depend on the component. Across the supported set these are:

| Property | Key used in `overrides` | Available on |
| - | - | - |
| **Background Color** | `backgroundColor` | All supported components except Image |
| **Border Color** | `borderColor` | All supported components except Image |
| **Border Width** | `borderWidth` | All supported components except Image |
| **Text Color** | `labelColor` | Text, Link |
| **Text Style** | `labelStyle` | Text, Link |
| **Link Color** | `linkColor` | Text |
| **Image Color** | `imageColor` | Image |

> [!WARNING]
>
> Only the keys in this table are supported. The Designer offers no other properties, and other keys are not applied consistently across platforms.

***

## Structure of conditional styling

1. **Condition:**
   * A string expression, evaluated like the [hide and disabled conditions](https://docs.flowx.ai/6.x/docs/building-blocks/ui-designer/ui-designer.md#hide-and-disabled-conditions).
   * Reference data store keys with `${key}`, for example `${user.age} > 30`. An empty or invalid expression evaluates to false.

2. **Overrides:**
   * A key-value map defining specific property-value pairs.
   * Overrides are applied when the condition evaluates to true.
   * Color values are objects: `{ "value": "#hex" }` for a custom color, or a theme `reference` when you pick a theme color. **Border Width** is a number.

Conditions are set per platform. The Designer stores them as a `conditionals` array in the component's style for each platform (Web, iOS, Android).

### Example

```json theme={"dark"}
"conditionals": [
  {
    "condition": "${user.age} > 30",
    "overrides": {
      "backgroundColor": { "value": "#FFD700" },
      "borderWidth": 2
    }
  },
  {
    "condition": "${user.subscription} == 'premium'",
    "overrides": {
      "borderColor": { "value": "#4CAF50" },
      "labelColor": { "value": "#FFFFFF" }
    }
  }
]
```

## Renderer behavior

* **Real-Time Evaluation**: Each condition is re-evaluated whenever the data it references changes, on Web, iOS, and Android.
* **Priority Handling**: If several conditions are met, all of their overrides apply. When two set the same property, the last condition in the sequence takes precedence.
* **Dynamic Application**: Styles are applied instantly upon condition satisfaction, enhancing UI responsiveness.

## Contextual menu options

* **Conditional styling** section **More** (⋮) menu: **Copy from \<platform>** and **Copy to \<platform>** copy all expressions between Web, Android, and iOS. Copied expressions are added after the expressions already on the target platform.
* Expression **More** (⋮) menu: **Copy to \<platform>** copies that one expression, and **Delete** removes it. To remove a single effect, use the **Delete** control on its row.

In a UI Flow, the copy options appear only on iOS and Android, and copy between those two. On Web, the section has no ⋮ menu and the expression menu offers only **Delete**.

![Conditional Styling section menu with Copy from Android, Copy from iOS, Copy to Android, and Copy to iOS](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/4.6/contextual_menu.png)

## Key notes

* **Dynamic Styling**: Facilitates platform-specific style overrides driven by real-time data conditions.
* **Scalability**: Designed to support iterative and scalable UI implementations.
* **Enhanced Usability**: Simplifies user interaction with intuitive UI/UX components, making style management more accessible and efficient.

> [!TIP]
>
> Combine conditional styling with data-driven expressions to create responsive, adaptable UI designs.


## Related topics

- [UI Designer best practices](https://docs.flowx.ai/6.x/docs/building-blocks/ui-designer/best-practices.md)
- [Screen configuration guide](https://docs.flowx.ai/6.x/docs/building-blocks/ui-designer/screen-configuration-guide.md)
- [FlowX.AI 4.6.0 Release Notes](https://docs.flowx.ai/release-notes/v4.x/v4.6.x/v4.6.0-january-2025/v4.6.0-january-2025.md)
- [Table](https://docs.flowx.ai/6.x/docs/building-blocks/ui-designer/ui-component-types/table.md)
- [UI Designer](https://docs.flowx.ai/6.x/docs/building-blocks/ui-designer/ui-designer.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.