Search code examples
adaptive-cards

How can I use "Only show when" on adaptive card


I have tried to search many places but I don't see any doc talk about how to use it.

https://i.sstatic.net/DTkM5.png


Solution

  • Without seeing more of your card, I think you need to remove the second $. Here's a very simple example:

    Card:

    {
        "type": "AdaptiveCard",
        "body": [
            {
                "type": "TextBlock",
                "size": "Medium",
                "weight": "Bolder",
                "text": "${title}",
                "$when": "${showTitle == true}"
            }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.3"
    }
    

    Data:

    {
        "title": "This is a title",
        "showTitle": true
    }
    

    If you change showTitle to false in the data, the text will no longer show.