Adaptive Card Renderer Specification
The following specification describes how implement an Adaptive Card renderer on any UI platform.
This content is not finished yet. Check back shortly.
- The SDK major and minor version SHOULD match the
- Patch/build SHOULD be used for renderer updates that don't have schema changes.
- A parser MUST check that it's valid JSON content
- A parser MUST validate against the schema (required properties, etc)
- The above errors MUST be reported to the host app (exception or equivalent)
- If unknown "types" are encountered they MUST BE DROPPED from the result
- Any alterations of the payload (like above) SHOULD be reported as warnings to the host app
- A parser MUST include additional properties on elements
speakproperty may contain SSML markup and MUST be returned to the host app as-specified
Parsing Host Config
- A renderer MUST implement a particular version of the schema.
AdaptiveCardconstructor MUST give the
Versionproperty a default value based on the current schema version
- If a renderer encounters a
minRequiredVersionproperty in the
AdaptiveCardthat is higher than the supported version, it MUST return the
AdaptiveCard consists of a
body is a collection of
CardElements that a renderer will enumerate and render in order.
- Each Element MUST stretch to the width of its parent (think
display: blockin HTML).
- A renderer MUST ignore unknown element types, and continue rendering the rest of the payload.
Spacing and Separators
spacingproperty on every element influences the amount of space between the CURRENT element and the one BEFORE it.
- Spacing MUST ONLY apply when there actually is an element preceding it. (E.g., won't apply to the first item in an array)
- A renderer MUST look up the amount of space to use from the
hostConfigspacing for the enum value applied to the current element.
- If the element has a
true, then a visible line MUST be drawn between the current element and the one before it.
- The separator line MUST be drawn using the
- A separator MUST ONLY be drawn if the item IS NOT the first in the array.
widthMUST be interpreted by "auto", "stretch" or a weighted ratio.
- A TextBlock MUST take up a single line unless the
- The text block SHOULD trim any excess text with an ellipsis (...)
- Adaptive Cards allow for a subset of Markdown and SHOULD be supported in
- See full markdown requirements
TextBlockallows DATE/TIME formatting functions that MUST be supported on every renderer.
ALL FAILURES MUST display the raw string in the card. No friendly message attempted. (The goal being to make the developer immediately aware there is a problem)
TODO: Include regex
- A renderer SHOULD allow host apps to know when all HTTP images have been downloaded and the card is "fully rendererd"
- A renderer MUST inspect the Host Config
maxImageSizeparam when downloading HTTP images
- A renderer MUST support
- A renderer SHOULD support
- TODO: What should the defaults be? Should they all share it? Should we embed a common hostConfig.json file in the binaries?
- TODO: I think HostConfig needs to be versioned as well for parsing?
HostConfig is a shared configuration object that specifies how an Adaptive Card Renderer generates UI.
This allows properties which are platform agnostic to be shared among renderers on different platforms and devices. It also allows tooling to be created which gives you an idea of the look and feel that card would have for a given environment.
- Renderers MUST expose a Host Config parameter to host apps
- All elements MUST be styled according to their respective Host Config settings
Native platform styling
- Each element type SHOULD attach a native platform style with the generated UI element. E.g., in HTML we added a CSS class to the element types, and in XAML we assign a specific Style.
- A renderer MUST allow host apps to override default element renderers. E.g., replace
TextBlockrendering with their own logic.
- A renderer MUST allow host apps to register custom element types. E.g., add support for a custom
- A renderer MUST allow host apps to remove support for a default element. E.g., remove
Action.Submitif they don't want it supported.
- If HostConfig
false, a renderer MUST NOT render any actions.
actionsproperty MUST be rendered as buttons in some kind of action bar, usually at the bottom of the card.
- When a button is tapped it MUST allow the host app to handle the event.
- The event MUST pass along all associated properties with the action
- The event MUST pass along the
AdaptiveCardwhich was executed
|Action.OpenUrl||Open an external URL for viewing|
|Action.ShowCard||Requests a sub-card to be shown to the user.|
|Action.Submit||Ask for all of the input elements to be gathered up into an object which is then sent to you through some method defined by the host application.|
Action.OpenUrlSHOULD open a URL using the native platform mechanism
- If this is not possible it MUST raise an event to the host app to handle opening the URL. This event MUST allow the host app to override the default behavior. E.g., let them open the URL within their own app.
Action.ShowCardMUST be supported in some way, based on the hostConfig setting. There are two modes: inline, and popup. Inline cards SHOULD toggle the card visibility automatically. In popup mode, an event SHOULD be fired to the host app to show the card in some way.
The Submit Action behaves like an HTML form submit, except that where HTML typically triggers an HTTP post, Adaptive Cards leaves it up to each host app to determine what "submit" means to them.
- When this MUST raise an event the user taps the action invokved.
dataproperty MUST be included in the callback payload.
Action.Submit, a renderer MUST gather all inputs on the card and retrieve their values.
- If Host Config
selectActionMUST NOT render as a touch target.
selectActionproperty, which SHOULD be executed when the user invokes it, e.g., by tapping the element.
- If HostConfig
falsea renderer MUST NOT render any inputs.
- Inputs SHOULD render with the highest fidelity possible. For example, an
Input.Datewould ideally offer a date picker to a user, but if this isn't possible on your UI stack, then the renderer MUST fall back to rendering a standard text box.
- A renderer SHOULD display the
- A renderer DOES NOT have to implement validation of the input. Users of Adaptive Cards must plan to validate any receieved data on their end.
Input value binding MUST be properly escaped
The object MUST be returned to the host app as follows:
We do not make any promises of input validation in adaptive cards, so it's up to the receiving party to properly parse the response. E.g., a Input.Number could return "hello" and they need to be prepared for that.
- A renderer SHOULD fire an event when an element's visibility has changed, allowing the host app to scroll the card into position.