Skip to main content

How to Change the Color of Text in an Adaptive Card

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Green for fine, amber for late, red for wrong: color makes a status readable at a glance. An Adaptive Card doesn't take color codes. A TextBlock names a color's meaning, and the app showing the card picks the actual color.

Syntax​

Card JSON
{
"type": "TextBlock",
"text": "<text>",
"color": "<color name>",
"isSubtle": <true or false>
}
PartWhat it does
colorControls the color of TextBlock elements. One of default, dark, light, accent, good, warning or attention
isSubtleIf true, displays text slightly toned down to appear less prominent.

The descriptions and the names are from Microsoft's TextBlock reference. The colors behind the names come from the app that shows the card, through its host config: What is HostConfig? lists good, warning, attention and the others among its font colors.

The Example​

A service status card has three lines, one per service, colored by their state: Good for Website: running, Warning for Nightly backup: running late, and Attention for File server: disk almost full. A last line, Checked at 09:00, is subtle.

Prerequisites​

  • An agent that sends Adaptive Cards in Microsoft Teams.

Step 1: Write the Card​

Cards/status.json
{
"type": "AdaptiveCard",
"version": "1.5",
"body": [
{ "type": "TextBlock", "text": "Service status", "size": "Large", "weight": "Bolder" },
{ "type": "TextBlock", "text": "Website: running", "color": "Good", "wrap": true },
{ "type": "TextBlock", "text": "Nightly backup: running late", "color": "Warning", "wrap": true },
{ "type": "TextBlock", "text": "File server: disk almost full", "color": "Attention", "wrap": true },
{ "type": "TextBlock", "text": "Checked at 09:00", "isSubtle": true, "wrap": true }
]
}

status.json in a macOS-style editor window: an Adaptive Card with a Service status title and TextBlocks Website: running with color Good, Nightly backup: running late with color Warning, File server: disk almost full with color Attention, and Checked at 09:00 with isSubtle true

This card writes the names with a capital letter, as Microsoft's Teams documentation lists them; the schema reference lists them in lowercase.

Step 2: See It in Teams​

Send the card from your agent, as How to Send an Adaptive Card in the Microsoft 365 Agents SDK in C# shows:

The Service status card in Teams: Website: running in green, Nightly backup: running late in amber, File server: disk almost full in red, and Checked at 09:00 in light grey

In Teams' light theme, the browser reported these colors for the three lines:

colorColor in Teams' light theme
Goodrgb(14, 112, 14), green
Warningrgb(131, 91, 0), amber
Attentionrgb(197, 15, 31), red

Common Mistakes​

MistakeWhat happensDo this instead
Color as the only sign of a problemPeople who can't tell the colors apart miss itSay it in the words too, as disk almost full does
Expecting the same color in every appEach app picks its own colors for the namesPick the name by meaning, not by look

Troubleshooting​

SymptomLikely causeFix
A color looks different elsewhereThe app's host config defines itExpected: the name sets the meaning

FAQ​

Can I color only part of a line?​

Not in a TextBlock, where color applies to its whole text. A RichTextBlock holds TextRuns, and each TextRun takes its own color.

Which color for an error message in a form?​

attention, the one Teams shows in red. It's what a form error looks like in How to Show an Error in a Teams Dialog in the Microsoft 365 Agents SDK in C#.

Conclusion​

To color text in an Adaptive Card, set a TextBlock's color to one of the seven names, such as good, warning or attention, and use isSubtle for lines that matter less. The app showing the card picks the actual colors: in Teams' light theme, green, amber and red.

Additional Resources​