Adaptive Cards
Adaptive Cards are a new way for developers to exchange card content in a common and consistent way.
Expressive cards, open framework, multiple platforms
Break outside the box of templated cards. Adaptive Cards let you describe your content as you see fit and deliver it beautifully wherever your customers are.
The simple open card format enables an ecosystem of shared tooling, seamless integration between producers and consumers, and native cross-platform performance on any device.
Get Started
full documentation for more
Check out theInstall
Node
npm install adaptivecards --save
CDN
Usage
NOTE: BREAKING CHANGE
The standalone
renderCard()
helper function was removed as it was redundant with the class methods. Please useadaptiveCard.render()
as described below.
Import the module
// Import the module:; // Or require it:var AdaptiveCards = ; // If you referenced the library from CDN, the global AdaptiveCards variable is already// defined and can be used directly:var adaptiveCard = ;
Render a card
// Author a card// In practice you'll probably get this from a service// see http://adaptivecards.io/samples/ for inspirationvar card = "type": "AdaptiveCard" "version": "1.0" "body": "type": "Image" "url": "http://adaptivecards.io/content/adaptive-card-50.png" "type": "TextBlock" "text": "Hello **Adaptive Cards!**" "actions": "type": "Action.OpenUrl" "title": "Learn more" "url": "http://adaptivecards.io" "type": "Action.OpenUrl" "title": "GitHub" "url": "http://github.com/Microsoft/AdaptiveCards" ; // Create an AdaptiveCard instancevar adaptiveCard = ; // Set its hostConfig property unless you want to use the default Host Config// Host Config defines the style and behavior of a cardadaptiveCardhostConfig = fontFamily: "Segoe UI, Helvetica Neue, sans-serif" // More host config options; // Set the adaptive card's event handlers. onExecuteAction is invoked// whenever an action is clicked in the cardadaptiveCard { ; } // For markdown support you need a third-party library// E.g., to use markdown-it, include in your HTML page:// <script type="text/javascript" src="https://unpkg.com/markdown-it/dist/markdown-it.js"></script>// And add this code to replace the default markdown handler:// AdaptiveCards.processMarkdown = function(text) { return markdownit().render(text); } // Parse the card payloadadaptiveCard; // Render the card to an HTML element:var renderedCard = adaptiveCard; // And finally insert it somewhere in your page:documentbody;
Webpack
If you don't want adaptivecards in your bundle, make sure the script is loaded and add the following the your webpack.config.json
moduleexports = ... externals: adaptivecards: var: "AdaptiveCards" ;