Customizing the Badge Color using a formula
Color the Stage column of a screen flow Data Table as badges, green for won and red for lost, driven by one formula field on Opportunity.
A sales manager reviews open deals in a screen flow before reassigning them. A gray column of stage names is slow to read. Shown as badges, Closed Won turns green, Closed Lost red, and late stages yellow, so the deals that need attention stand out at a glance.
The color comes from a text formula field on Opportunity. The Data Table reads it on every row and uses it as the badge variant.

Before you start
A screen flow with an Avonni Data Table that lists Opportunities. If you are starting from scratch, follow Learn the Basics first.
The table uses the Query or Variable data source. See Data Source.
Permission to create fields in Object Manager.
Steps
Create the variant formula field
In Setup, open Object Manager > Opportunity > Fields & Relationships > New.
Choose Formula, name the field
Stage Variant, and set the return type to Text.Paste this formula:
Every value the formula returns must be one of the badge variants listed in Badge variants, spelled exactly.
Turn the Stage column into a badge
Select the Data Table on the screen and click Open Component Builder.
In the preview, click the chevron on the Stage column header and choose Type Attributes.
Set Type to Badge.
Next to Variant, turn on the Field Name toggle so each row reads its own value from a field (how the toggle works). For Variant it shows a text box, not a field list: type the API name of the formula field, for example
Stage_Variant__c.Click Save, then Done.
The badge text is still the stage name. Only its color comes from the formula.
Badge variants
These are the values the Variant attribute accepts. Your formula must return them exactly, in lowercase.
base
Default, neutral
brand
Highlight in the brand color
inverse
Strong emphasis
alt-inverse
Strong emphasis, alternative style
success
Won, done, approved
info
In progress
warning
Needs attention
error
Lost, rejected, overdue
offline
Inactive
Troubleshooting
Related tutorials
How to conditionally color cells: color the whole cell background instead of a badge.
How to set column visibility: show a column only to the users who need it.
How to add images on the Data Table: progress bars, ratings, avatars and the other visual column types.
Last updated
Was this helpful?
