You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Microsoft Teams中格式化Adaptive Card按钮?寻求渲染建议

Hey there! Let's figure out how to fix your Adaptive Card button formatting in Microsoft Teams — I’ve sorted through plenty of these issues before, so here’s what you need to know to get your buttons looking exactly how you want them:

Key Button Formatting Tweaks for Teams Adaptive Cards

1. Control Layout Direction (Horizontal/Vertical)

By default, buttons might stack vertically, but if you want them side-by-side, wrap them in an ActionSet component and set the orientation to horizontal. For vertical stacking with better spacing control, use vertical instead. Here’s an example:

{
  "type": "ActionSet",
  "orientation": "horizontal",
  "spacing": "medium",
  "actions": [
    {
      "type": "Action.Submit",
      "title": "Confirm",
      "style": "positive"
    },
    {
      "type": "Action.Submit",
      "title": "Cancel",
      "style": "destructive"
    }
  ]
}

Adjust the spacing value (small, medium, large) to tweak the gap between buttons.

2. Use Built-In Button Styles

Teams supports native button styles that match its UI — these will make your cards feel more integrated:

  • positive: Green button for confirmatory actions
  • destructive: Red button for high-risk actions (like deleting)
  • default: Neutral gray style (used if you don’t specify a style)
    Just add the style property to your action, like in the example above.

3. Adjust Button Size & Width

If your buttons are too narrow or too wide, use the width property to control their size:

  • width="auto": Button shrinks to fit its text
  • width="stretch": Button expands to fill the full width of its container
    Example of a full-width button:
{
  "type": "Action.Submit",
  "title": "Full-Width Action",
  "style": "positive",
  "width": "stretch"
}

4. Group Buttons with Containers

For more complex layouts (e.g., a row of buttons followed by a vertical stack), nest multiple ActionSets inside a Container component. You can add spacing and separators to keep groups distinct:

{
  "type": "Container",
  "spacing": "large",
  "separator": true,
  "items": [
    {
      "type": "ActionSet",
      "orientation": "horizontal",
      "actions": [/* Your horizontal button group */]
    },
    {
      "type": "ActionSet",
      "orientation": "vertical",
      "spacing": "small",
      "actions": [/* Your vertical button group */]
    }
  ]
}

5. Test for Teams Compatibility

Keep in mind that some Adaptive Card features behave slightly differently in Teams compared to the standard spec. Always preview your card directly in Teams (send it to yourself or use the developer preview tools) to check how buttons render — avoid relying on generic Adaptive Card previews, since they might not match Teams’ actual behavior.

内容的提问来源于stack exchange,提问作者shehanaaz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 13:48:14