@dbx-tools/ui-teams

中文文档
0.9.144发布于 2026/10/20Apache-2.0ES Module构建来源已验证近 30 天下载 2849

React renderer for Microsoft Teams Adaptive Cards and Teams chat surfaces

原始使用文档
文档目录8 节
  1. Quick start
  2. Package fit
  3. Package contents
  4. Configure the chat preview
  5. Render a card
  6. Add a live preview page
  7. Styles
  8. Package exports

@dbx-tools/ui-teams

Render Microsoft Teams Adaptive Cards or a Teams-style conversation preview in a React application. This browser package uses the adaptivecards renderer, card contracts from @dbx-tools/shared-teams, and the shared @dbx-tools/ui foundation.

Quick start

import { TeamsChat } from "@dbx-tools/ui-teams/react";

export function SupportChat() {
  return <TeamsChat className="h-full" />;
}

Import the stylesheet after your AppKit UI theme.

Package fit

Use this package with the @dbx-tools/teams server plugin. Import @databricks/appkit-ui/styles.css before this package's stylesheet. The components don't read AppKit client configuration. TeamsChat and AdaptiveCardGallery use the explicit endpoint and buildEndpoint props, which default to /api/teams/messages and /api/teams/card.

The browser preview doesn't implement Microsoft Bot Framework authentication. The /messages route returns activities in the HTTP response only when the server enables its development-only allowUnauthenticated option. For a local preview against the normal server configuration, set endpoint="/api/teams/activity". Keep Microsoft Teams bot credentials and Connector API delivery on the server.

Use @dbx-tools/ui-mastra for Mastra chat and @dbx-tools/ui for common AppKit, authentication, email, and search components.

Package contents

  • TeamsChat posts Bot Framework activities and renders reply attachments as Adaptive Cards. It keeps one conversation ID per mount, cancels an active request on unmount, and supports starter prompts.
  • AdaptiveCardView renders a compiled Adaptive Card and supports Action.OpenUrl handling through onOpenUrl.
  • AdaptiveCardGallery edits a CardSpec, compiles it through POST /api/teams/card, and renders the result.
  • CARD_SAMPLES provides examples with facts, link actions, and notes.
  • TextBlock Markdown uses marked. If parsing fails, the renderer displays the source as plain text.

Configure the chat preview

import { TeamsChat } from "@dbx-tools/ui-teams/react";

const Chat = () => <TeamsChat className="h-full" />;

Point endpoint elsewhere if the plugin is mounted under a different name, and pass agentId to converse with a specific agent instead of the server's default. starters replaces the built-in DEFAULT_STARTERS prompts.

Render a card

import { AdaptiveCardView, type AdaptiveCard } from "@dbx-tools/ui-teams/react";

const Preview = ({ card }: { card: AdaptiveCard }) => (
  <AdaptiveCardView card={card} className="ac-container" />
);

AdaptiveCardView renders any compiled Adaptive Card document, including one returned by the create_teams_card tool, the plugin's buildCard export, or the /api/teams/card route. Card text is treated as Markdown, matching how Teams renders a TextBlock.

Add a live preview page

import { AdaptiveCardGallery } from "@dbx-tools/ui-teams/react";

const Cards = () => <AdaptiveCardGallery />;
export default Cards;

Add <AdaptiveCardGallery /> to a route. It posts the edited CardSpec to the @dbx-tools/teams plugin's /api/teams/card route and renders the compiled card. Point it at a different mount with buildEndpoint.

Styles

Import the stylesheet once from the host app's Tailwind entry, after Tailwind and your AppKit UI theme:

@import "tailwindcss";
@import "@databricks/appkit-ui/styles.css";
@import "@dbx-tools/ui-teams/styles.css";

The Teams stylesheet imports the shared @dbx-tools/ui foundation and uses AppKit semantic tokens. Import it once from the host application's Tailwind entry point.

Package exports

  • ./react: TeamsChat, DEFAULT_STARTERS, AdaptiveCardView, AdaptiveCardGallery, CARD_SAMPLES, and the re-exported Activity, AdaptiveCard, CardResult, and CardSpec types.
  • ./styles.css: AppKit-token-based gallery styles and a minimal Adaptive Card container skin.

版本与发布记录

@dbx-tools/ui-teams 共发布 258 个版本,首次发布于 2026/07/28;过去 12 个月发布了 258 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.144latest2026/10/2023 天前
0.9.1432026/10/2023 天前
0.9.1412026/10/2023 天前
0.9.1402026/10/2023 天前
0.9.1392026/10/2023 天前
0.9.1382026/10/1923 天前

关于 @dbx-tools/ui-teams 的常见问题

@dbx-tools/ui-teams 是什么?

React renderer for Microsoft Teams Adaptive Cards and Teams chat surfaces

如何安装 @dbx-tools/ui-teams?

在项目目录运行 npm install @dbx-tools/ui-teams,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(~19.2.4)、react-dom(~19.2.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dbx-tools/ui-teams 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dbx-tools__ui-teams 是否存在。

@dbx-tools/ui-teams 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dbx-tools/ui-teams 可以商用吗?

@dbx-tools/ui-teams 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dbx-tools/ui-teams 的下载量有多少?

根据 npm 官方下载统计,@dbx-tools/ui-teams 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,849 次,日均约 95 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dbx-tools/ui-teams 还在维护吗?

最新版本 0.9.144 发布于 2026/10/20(23 天前);至今共发布 258 个版本,其中过去 12 个月发布了 258 个;首次发布于 2026/07/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。