Apply Conditional Cell Styling
Tint table cells with SLDS classes, either the same style on every row or a style picked per row by a formula field, so key values stand out.
A sales operations lead scans a long pipeline table and wants the Stage cells tinted like a spreadsheet: shaded for early deals, orange near the close, green for won, red for lost. Each column has an SLDS Cell Class setting. Type classes into it to style every row the same way, or bind it to a formula field to pick the style row by row.

Before you start
A Data Table on Opportunity with a Query data source, showing at least the Opportunity Name, Stage and Amount columns.
Permission to create a formula field on Opportunity (Customize Application).
Steps
Create the Stage Style formula field
The formula returns the SLDS classes to apply to each row's cell. It uses the same stage groups as Apply Badge Color-Coding and Add Status Indicators.
In Setup, open Object Manager, then Opportunity, then Fields & Relationships, and click New.
Choose Formula, name the field
Stage Style, and set the return type to Text.Paste this formula, then save:
Any other stage returns an empty value and keeps the default cell style.
Save and test
Save the component and open the page that holds it. The Stage cell of a Prospecting deal is shaded gray, a Negotiation/Review deal is light orange, a Closed Won deal is light green and a Closed Lost deal is pink. Theme classes tint the whole cell and adjust its text color. The other columns keep their default style.
Same style on every row
When the style does not depend on the record, skip the formula. Leave the Field Name toggle off and type the classes into SLDS Cell Class, separated by spaces. For example, slds-text-title_bold on the Amount column bolds every amount.
SLDS classes for cell styling
These are standard Salesforce Lightning Design System utility classes. Combine several with a space, for example slds-theme_shade slds-text-title_bold.
slds-theme_shade
Light gray background
slds-theme_info
Light blue background
slds-theme_warning
Light orange background
slds-theme_success
Light green background
slds-theme_error
Pink background
slds-theme_inverse
Dark blue background
slds-theme_alert-texture
Striped texture, added on top of a background class
slds-text-color_weak
Gray text
slds-text-color_success
Green text
slds-text-color_error
Red text
slds-text-color_inverse
White text, for dark backgrounds
slds-text-title_caps
Small uppercase text
slds-text-title_bold
Bold text
Troubleshooting
Related tutorials
Apply Badge Color-Coding: color the value itself, with your own hex codes.
Add Status Indicators: a compact dot when the table is narrow.
Configuring Data Grouping: group rows by stage so the tinted cells line up.
Last updated
Was this helpful?

