// Create an AdaptiveCard instance
var adaptiveCard = new AdaptiveCards.AdaptiveCard();
// Set its hostConfig property unless you want to use the default Host Config
// Host Config defines the style and behavior of a card
adaptiveCard.hostConfig = new AdaptiveCards.HostConfig({
fontFamily: "Segoe UI, Helvetica Neue, sans-serif"
// More host config options
});
// Render the card to an HTML element:
var renderedCard = adaptiveCard.render();
個性化
有 3 種方式可以自訂自適應卡片的呈現方式。
- 主機設定
- CSS 樣式
- 自定義元素渲染
主機配置
主機設定是所有轉譯器都瞭解的共享組態物件。 這可讓您定義通用樣式(例如字型系列、字型大小、預設間距)和行為(例如,每個平臺轉譯器會自動解譯的動作數目上限)。
目標是透過每個平台上的轉譯器生成的原生 UI 看起來非常類似,並且您只需付出最少的努力。
var renderOptions = {
...
hostConfig: {
// Define your host config object here
// See the HostConfig docs for details
}
};