Tips and tricks to create stunning Adaptive Cards (Updated Mar ’22)

A simple Adaptive Card for your business takes less than 10 minutes to make. But as you start to make more sophisticated layouts you will usually run into common issues where the data you want to show in your Card maybe isn’t 100% what you need it to be, or is just too much to comfortably fit into your layout.

In this post I listed examples of cool little hacks that we’ve accumulated over time that helped push the envelope on what an Adaptive Card can do. Some of these use Adaptive Expressions, but others are just thinking outside the box a little.

Trim to first name

Let say you have an API that gives you the user’s name as “John Hancock” but you want to address the user as just “John” in your Card.

Turn timestamps into “x hours ago”

Most APIs send timestamps in UNIX format, like 2021-09-17T00:00:33.25. But most users prefer relative timestamps to be a little easier to read than that.

Ordinarily you need a library like moment.js that does this kind of transformation. But, in a pinch, you can get very close to this using the following Adaptive expression.

Assemble email addresses

If you want to show a user’s email address, but your API isn’t providing it, then maybe you can “build” the email using their name and company name.

Make tabs

Tab interfaces are popular, but not supported in Adaptive Cards. Or are they?

With this trick you can create a Card that has at least two tabs – although be warned that the widths need tinkering with to display this properly on small screens.

Include icons in the Card

Adaptive Cards can’t host their own images or icons, so you will usually need a URL and capacity to host these yourself elsewhere (for example through a CMS). However, there is one hack to get around this that works at least for icons. You can base64 them, for example with a tool like Elmah.

This makes the Card’s payload quite large so use it with caution and remember that some host apps might have size restrictions that you could run into using this.

Conditional highlighting

If you want text to be either green or red depending on a value, you can conditionally highlight text, or, even switch out arrow symbols to show an upwards or downwards trend. In our example below this is the values we used:

"change": "2.5",
"yesterday": "7"

Create fallback text

Sometimes the data you get from APIs is not as uniform as we want. Let’s say you want to make a Card that shows peoples’ job titles beneath their name. Until one record doesn’t contain the job title, causing an awkward change in height.

Wouldn’t it be cool to have a fallback of some kind, say to show the email address when there isn’t a job title?

Create a mini timeline

Whether your showing customer activity or progress of a process, a vertical timeline could be a quirky little addition to your Adaptive Card design. Here’s how to do it:

Use backgrounds for stunning designs

Whether it’s a welcome message, or some digital signage you want to place on the corporate intranet, Adaptive Cards can show background images which make them ideal for your great designs.

Expanding line items

In order to declutter an Adaptive Card, it might be useful to offload some details into a little section that expands and collapses. This is a relatively simple way to get there:

Accordion

Building on top of the expand/collapse function, you could also get whole accordion style sections. Whenever you click on a headline, the respective section opens or closes.

Pseudo active state

Let’s say you want to offer a Like button. On Facebook you press it, it turns bright blue, you know it’s pressed. Adaptive Cards’ buttons don’t offer a similar activated state, but you can get there by using the Action.ToggleVisibility button.

Filtered lists

You know the problem: you get a JSON file that has 25 items but you only want to show the ones that are, say, green. With an Adaptive Expression you can filter items from your array based on a matching attribute.

Turn an integer into a string

Let’s say your JSON has a count of the number of outages your system has. But you can’t show this count inside of your Adaptive Card because it’s just an integer, and Adaptive Cards can only bind to strings wrapped in "".

Rescue has arrived. There is an Adaptive Expression you can inside of your Card that turns your integer into a string.

Count items in an array

Let’s say you have a list but you want to get a count of how many of them are red items, versus other colors. You can wrap this into two Adaptive Expressions, the first count is responsible to output you a number, and the inner function where filters the output for the attribute(s) you specify.

Empty state for a list

If you have an Adaptive Card list but the array is empty, the list just unceremoniously vanishes. This could make you or your users question if the Card could be broken, when it’s just hasn’t anything to show you. To avoid that, empty states are a popular way to signpost a list is deliberately empty.

In this below example, if there are no 🟡 items in our list, we display the empty state container.

~~~

Did you find these hacks useful? If so, you might also be interested in ready-to-use business templates for Adaptive Cards.

Related Posts
Read More

How to add apps to Viva Connections dashboard

Viva Connections is the new gateway to other Viva services within Microsoft’s new suite of employee experience tools and resources. The Dashboard, specifically, shows users little summaries of other Viva services as a way conveniently track one metrics and jump right into relevant resources. Administrators can create their own Cards for the Dashboard, by adding Card designer Cards to the Dashboard. These take any Adaptive Card schema that you can make yourself from scratch or by editing one of the many templates that are available. However, this built-in Card designer Card has no way to connect to any data sources…
Read More

How to embed an Outlook Calendar in SharePoint (without the headaches)

If you’ve ever tried to display an Outlook calendar on a SharePoint page, you know that it’s not possible with Microsoft’s built-in options, the Events web part or Group Calendar web part. Neither let you showcase events from a specific Outlook calendar. Let’s explore why these native solutions might not meet your needs and introduce a seamless alternative. The problem: built-in choices have limitations 1. Events web part The Events Web Part requires you to manually add each event, similar to publishing news articles. This process is not only time-consuming but also prone to errors, especially when managing multiple events.…
Read More

How to embed a Confluence page in SharePoint – Step-by-step integration guide

In many organizations, Atlassian Confluence serves as a vital knowledge base while SharePoint Online is the hub for intranet content and collaboration. Instead of keeping these platforms siloed, you can embed Confluence pages directly in your SharePoint intranet to create a unified experience. By using a Confluence SharePoint connector (in this case, a web part available from the SharePoint Store), you bring Confluence content into SharePoint seamlessly. This approach offers several benefits: your team can access wiki articles, documentation, and project notes from Confluence without leaving SharePoint, information stays up-to-date (no need for manual copy-paste), and you avoid the hassle…
Read More

Top 4 SharePoint Dashboard Apps

Dashboards have traditionally been a staple for real-time data visualizations, of interest mostly to business intelligence users, data analysts or perhaps marketers.