How to Conditionally Color Cells
Overview
This tutorial explains how to customize the appearance of cells within an Avonni Data Table component in Salesforce Screen Flows using SLDS classes. You'll learn two distinct approaches to styling:
Static Styling: Applying a consistent, uniform look to every cell in a specific column (e.g., making all "Amount" values bold).
Dynamic Conditional Styling: Implementing row-by-row formatting where each cell's appearance changes based on its data. You will learn how to achieve this by leveraging Salesforce Formula Fields created directly on your objects.
Example Scenario
Imagine displaying a list of Opportunities in a data table. To help users quickly identify the health of a deal, you want the Stage column to be color-coded based on its value:
Closed Won appears with a green background.
Closed Lost appears with a red background.
Needs Analysis appears with a yellow background.
Instead of manual configuration for each row, the Data Table reads a "Style" formula field from the Opportunity record to automatically determine the correct color.

Note
While this tutorial uses Opportunity Stages as the primary example, this technique is the standard approach for any field where visual indicators are needed, such as Case Priorities, Project Statuses, or Lead Ratings
What You'll Learn
By the end of this tutorial, you'll know how to:
Apply Static Styling: Make all cells in a column look the same (e.g., all bold or all centered).
Create Object-Level Logic: Build a formula field on a Salesforce Object specifically for styling.
Use SLDS Classes: Master the class names that control colors, backgrounds, and text styles.
Map Dynamic Data: Connect your Salesforce-style formula to the Data Table to automatically update for every row.
Prerequisites
Before starting this tutorial, you should have:
An Avonni Data Table component is already configured in your flow.
Data displayed in the table from a Record Collection or query.
Permissions to create fields in the Salesforce Object Manager (or an existing styling formula field ready to use).
Basic familiarity with Salesforce Flow Builder.
Understanding the SLDS Cell Class Attribute
The key to styling cells is the SLDS Cell Class attribute, found in each column's configuration.
How to access it
Select your Avonni Data Table component in the flow.
In the properties panel, find the Columns section.
Click to expand or edit a specific column (e.g., the "Stage" column).
Look for Cell Attributes or Advanced Settings.
Locate the SLDS Cell Class input field.
This field accepts Salesforce Lightning Design System (SLDS) class names. You can either enter static class names (to style the whole column) or map the field to a Formula Field from your Object to change the style dynamically row-by-row.
Choosing Your Styling Method
There are two ways to use the SLDS Cell Class attribute, depending on your goals. You can either enter static class names manually or map the field to a Formula Field from your Object to change the style dynamically row-by-row.
Use Method 1 (Static) if you want the entire column to use a singleshare one fixed style.
Use Method 2 (Dynamic) if you want colors and styles to change automatically based on each record's data.
Method 1: Static Styling (Uniform Style for All Rows)
Use this method when you want every cell in a specific column to have the same appearance, regardless of the data value.
When to Use Static Styling
Emphasizing an entire column (e.g., making all monetary values bold)
Creating visual hierarchy (e.g., headers or totals with different backgrounds)
Applying consistent branding (e.g., all status fields in a specific color)
Step-by-Step Instructions
Select Your Column
Click on your Avonni Data Table component
Navigate to the Columns section in properties
Select the column you want to style
Enter SLDS Classes
Find the SLDS Cell Class field
Type the SLDS class names directly (separate multiple classes with spaces)
Example 1 - Green bold text:
Example 2 - Light grey background with capitalized text:
Example 3 - Red text for a critical column:
Save and Test
Click Done for the column configuration
Save your flow and run it
Verify that all cells in the column display the styling

Useful SLDS Classes Reference
Here are commonly used SLDS classes you can combine (separate with spaces)
Background Colors
slds-theme_success- Green backgroundslds-theme_error- Red backgroundslds-theme_warning- Yellow backgroundslds-theme_info- Blue backgroundslds-theme_shade- Light grey backgroundslds-theme_alt-inverse- Dark grey backgroundslds-theme_inverse- Dark blue/grey background
Text Colors
slds-text-color_success- Green textslds-text-color_error- Red textslds-text-color_warning- Dark yellow/orange textslds-text-color_inverse- White text (for dark backgrounds)slds-text-color_default- Standard text colorslds-text-color_weak- Grey text
Text Styles
slds-text-title_caps- ALL CAPS TEXTslds-text-heading_small- Bold text (heading style)slds-text-body_regular- Regular body textslds-truncate- Truncate long text with ellipsis
Pro Tip
You can combine background and text colors. For readability, use slds-text-color_inverse (white text) with dark backgrounds like slds-theme_error.
Method 2: Dynamic Conditional Styling (Style Per Row)
This approach allows each cell's appearance to change based on its specific data value (e.g., color-coding risk levels or statuses). To achieve this, you use a Formula Field created directly on the Salesforce Object.
Understanding How Object-Level Styling Works
Instead of writing logic inside the Flow, you create a "Style" field on your object (like Opportunity or Case) in the Salesforce Object Manager. This field calculates which SLDS classes to apply based on other values in the record. The Avonni Data Table then reads this string for every row and applies the styling automatically.
Step-by-Step: Highlighting Opportunity Stages
Map the Field in your Flow
Once the field is created, you need to tell the Avonni Data Table to use it for styling.
Open your Flow and select the Avonni Data Table component.
Go to the Columns section and select the Stage column.
Locate the SLDS Cell Class input field.
Important: Toggle the Field Name option to select the field to map for the SLDS Cell Class. Then, select the API name of the formula field you just created on your object
Select your new formula field from the list

What the Data Table Does:
For Rows 1, 2, and 3: The table identifies the Value Proposition stage for these records. Based on your
CASEformula, it retrieves theslds-theme_inverseclass and renders these cells with a dark navy background and white text.
Troubleshooting
The formula doesn't seem to evaluate - all cells look the same
Verify you select the formula field name rather than typing text
Check that the field API name in your formula exactly matches the column's field name
Ensure the formula data type is set to "Text"
Look for syntax errors in the formula (mismatched parentheses, incorrect field references)
I get an error: "Field does not exist"
The field API name in your formula doesn't match your object's actual field
Double-check the field API name in Object Manager
Remember to include
__cfor custom fieldsVerify you're using the correct field from the correct object
The styling appears but the colors are wrong
Review the SLDS class names you're returning in the formula
Some classes require others (e.g.,
slds-theme_errorworks best withslds-theme_shade)Try the classes individually first to test them
Some rows show styling, others don't
Your formula might not account for all possible values
Add an else condition to handle unexpected values
Check for null or blank values in your data
The formula syntax shows an error
Count your opening and closing parentheses - they must match
Verify you're using straight quotes (") not curly quotes ("")
Check for typos in field API names
Ensure proper spacing and comma placement
Advanced Techniques
Once you are comfortable with basic stage-based styling, you can create more sophisticated logic within your Salesforce Object Formula Field to handle complex business requirements. These examples use standard Salesforce objects and functions to show what is possible.
Styling Based on Multiple Fields
You can evaluate two or more fields at once to create a "Critical" alert style. For example, on the Case object, you might want to highlight cases that are both "High Priority" and "New".
Example
Result: High-priority new cases get a red background with bold white text; other high-priority cases just get a yellow background.
Using CASE() for Clean Logic
For picklist fields with many options, like Lead Status, a CASE() function is much easier to read and maintain than nested IF() statements.
Example
Result: Each lead status is assigned a distinct color (blue, yellow, green, or grey) based on its current value.
Percentage and Range-Based Color Coding
You can create "heat maps" based on numeric fields, such as the Probability percentage on an Opportunity.
Example
Result: High probability (75%+) is green, medium probability is yellow, and low probability is red.
Combining Text and Background Styling
Use multiple SLDS classes to create a high-impact visual hierarchy for your most important data, such as large Opportunity Amounts.
Example
Result: Opportunities over $500,000 appear in a dark navy "inverse" theme with bold, capitalized text to ensure they stand out to the user.
Need More Help?
If you have questions about implementing conditional cell styling for your specific use case, or if you encounter issues with formulas or styling, don't hesitate to reach out. We're here to help you create visually effective and user-friendly data tables with Avonni components.
Last updated
Was this helpful?
