AgentSkillsCN

coherence-ui

为构建UI提供全面参考——Coherence设计系统(微软内部用于C+AI的设计系统)。在使用Coherence组件(来自`@charm-ux/cui`的`cui-*` Web组件)构建UI时使用此功能,或当用户询问Coherence组件的使用方法、使用指南、无障碍性,或API相关问题时使用此功能。此外,在使用Coherence模板(仪表板、表单、设置)、任务流程(批量编辑、内联编辑、收藏夹、保存预设),或遵循Coherence UX指南(无障碍性、AI模式、数据可视化、UI写作)时也应使用此功能。当用户询问Coherence设计令牌、主题化、颜色、间距、字体、阴影、CSS自定义属性,或任何`--color-*`、`--spacing-*`、`--font-*`变量时,也可使用此功能。只要提及Coherence、`cui-`组件、`@charm-ux/cui`、设计令牌、主题CSS,或构建应遵循Coherence设计系统的UI时,均可触发此功能。

SKILL.md
--- frontmatter
name: coherence-ui
description: Comprehensive reference for building UIs with the Coherence Design System (Microsoft's internal design system for C+AI). Use when building UI with Coherence components (`cui-*` web components from `@charm-ux/cui`), or when the user asks about Coherence component usage, guidance, accessibility, or API. Also use when composing pages with Coherence templates (dashboard, form, settings), task flows (bulk edit, inline edit, favorites, save presets), or following Coherence UX guides (accessibility, AI patterns, data visualization, writing for UI). Also use when the user asks about Coherence design tokens, theming, colors, spacing, typography, shadows, CSS custom properties, or any `--color-*`, `--spacing-*`, `--font-*` variable. Triggers: any mention of Coherence, `cui-` components, `@charm-ux/cui`, design tokens, theme CSS, or building UI that should follow the Coherence design system.

Coherence UI Skill

Build UIs using the Coherence Design System — Microsoft's component library for C+AI products.

Default output: React. Always generate React components using the @charm-ux/cui/react wrappers unless the user explicitly asks for plain HTML web components or another format.

Quick Reference

  • Package: @charm-ux/cui
  • React import (preferred): import { CuiButton } from '@charm-ux/cui/react'
  • Web component import (alternate): import '@charm-ux/cui/dist/components/<name>/index.js'
  • Tag prefix (web components): cui- (e.g. cui-button, cui-dialog)
  • React naming convention: Cui + PascalCase component name (e.g. CuiButton, CuiCard, CuiDialog)
  • Design system site: https://coherence-ftekb0dcfpcjb3gv.b02.azurefd.net

Data Sources

Three complementary sources provide a complete picture of every component and the design system. Consult the relevant source(s) for the task at hand.

1. Live API Manifest (primary — source of truth for API)

URL: https://coherence-ftekb0dcfpcjb3gv.b02.azurefd.net/cdn/latest/custom-elements.json

Fetch this URL to get the machine-readable API for any component. It follows the Custom Elements Manifest schema. For each component it provides:

  • Attributes — exact names, types, defaults, descriptions
  • Events — names, detail types
  • Slots — names, descriptions
  • CSS Custom Properties — all themeable hooks
  • CSS Parts — all styleable internal parts
  • Dependencies — which sub-components are auto-registered
  • Class hierarchy — superclass and inherited members

How to look up a component: Find the module whose path matches src/components/<slug>/<slug>.ts, then read its declarations array for the entry with customElement: true.

Example: to look up cui-button, find the module with path: "src/components/button/button.ts" → its declaration is CuiButton.

2. Theme CSS — Design Tokens (source of truth for theming, colors, spacing, typography)

URL: https://coherence-ftekb0dcfpcjb3gv.b02.azurefd.net/cdn/latest/themes/cui/theme.css

Fetch this URL when answering questions about design tokens, theming, colors, spacing, typography, shadows, borders, animation timing, or component-level CSS variables. This auto-generated CSS file defines all CSS custom properties on :root / :host and is the single source of truth for token names and values.

What it contains:

CategoryToken prefix / examplesDescription
Color palette--color-brand-{10–160}, --color-neutral-{0–100}, --color-danger-*, --color-success-*, --color-warning-*, --color-caution-*Raw color scale with -alt contrast pairs
Semantic colors--neutral-foreground{1–4}, --neutral-background{1–6}, --brand-foreground*, --brand-background*, --subtle-background*, --compound-brand-*Role-based color tokens with hover/pressed/selected/disabled states
Status colors--danger-background*, --danger-foreground*, --success-*, --warning-*, --severe-*Semantic status indicators
Stroke / border colors--neutral-stroke{1–3}, --neutral-stroke-accessible*, --neutral-stroke-subtle, --brand-stroke*, --compound-brand-stroke*, --stroke-focus{1,2}, --transparent-stroke*Semantic border/stroke tokens
Overlay / scrollbar--background-overlay, --scrollbar-overlayModal overlay and scrollbar colors
Typography--font-family-base, --font-family-numeric, --font-family-monospace, --font-size-base{100–600}, --font-size-hero{700–1000}, --font-weight-*, --line-height-*Type scale and font stacks
Spacing--spacing-none through --spacing-xxxlLayout spacing scale (0–32 px)
Borders--border-radius-{none,sm,md,lg,xl,circular}, --border-width-{none,thin,thick,thicker,thickest}Border radius and width tokens
Default border--default-border, --default-border-size, --default-border-style, --default-border-colorShorthand border defaults used by many components
Shadows--shadow-{0,2,4,8,16,28,64}, --drop-shadow-*Elevation / shadow tokens
Animation--duration-{ultra-fast…ultra-slow}, --timing-function-{accelerate,decelerate,easy-ease,linear}-*Motion timing tokens
Focus--focus-outline, --focus-outline-color, --focus-outline-offset, --focus-outline-size, --focus-outline-styleGlobal focus ring styling
Component defaults--button-*, --form-control-*, --link-*, --heading-*, --body-*Pre-composed component-level variables that reference the above tokens

How the theme CSS relates to component reference docs:

The theme CSS defines global defaults for ~578 tokens. Of those, about 51 are also documented in component reference files (mainly --button-*, --form-control-*, and --default-border). Component reference docs additionally list component-specific CSS custom properties (e.g. --accordion-item-*, --card-*, --dialog-*, --checkbox-*) that are not in the theme CSS — those are defined inside individual component stylesheets and can still be overridden. Use both sources together: the theme CSS for token values/names and the component refs for per-component override hooks.

When to fetch: Any time the user asks about available colors, spacing values, font sizes, shadow levels, how to theme a component, what CSS variables exist, or when you need the exact token name/value for a style.

3. Design Guidance References (supplementary — design, UX, and examples)

The reference docs below contain information the manifest does not have:

  • When to use / when not to use a component
  • Anatomy diagrams and layout rules
  • Dos and don'ts
  • Accessibility guidance specific to the component
  • Code examples showing composition patterns
  • Content/writing guidelines

Workflow

When the user asks to build UI or use a Coherence component:

  1. Identify the component(s) needed from the index below or the manifest
  2. Fetch the manifest to get the precise API (attributes, types, defaults, slots, events, CSS properties, dependencies)
  3. Read the component reference file (if one exists) for design guidance, dos/don'ts, accessibility rules, and code examples
  4. Combine both — use guidance to decide how to compose the UI; use the manifest as the source of truth for exact attribute names, types, and values
  5. If no reference file exists, the manifest alone is sufficient for API usage — apply general Coherence accessibility and layout rules from the guides below
  6. For theming, colors, spacing, typography, or shadows — fetch the theme CSS to get the exact token names and values
  7. Output React by default — generate a React component (.tsx) using @charm-ux/cui/react wrappers. Only output plain HTML web components (<cui-*>) if the user explicitly requests it.

When composing a full page or layout, also read the relevant template and task flow references.

Component Index

Reference files contain design guidance and code examples only — not API details. Always fetch the manifest for API data.

Components with a reference file (66 — guidance available):

ComponentTagReference
Accordioncui-accordionreferences/components/accordion.md
Accordion Itemcui-accordion-itemreferences/components/accordion-item.md
AI Chatcui-ai-chatreferences/components/ai-chat.md
App Framecui-app-framereferences/components/app-frame.md
Avatarcui-avatarreferences/components/avatar.md
Badgecui-badgereferences/components/badge.md
Bannercui-bannerreferences/components/banner.md
Breadcrumbcui-breadcrumbreferences/components/breadcrumb.md
Breadcrumb Itemcui-breadcrumb-itemreferences/components/breadcrumb-item.md
Buttoncui-buttonreferences/components/button.md
Button Groupcui-button-groupreferences/components/button-group.md
Cardcui-cardreferences/components/card.md
Carouselcui-carouselreferences/components/carousel.md
Character Countercui-character-counterreferences/components/character-counter.md
Checkboxcui-checkboxreferences/components/checkbox.md
Content Framecui-content-framereferences/components/content-frame.md
Data Gridcui-data-gridreferences/components/data-grid.md
Dialogcui-dialogreferences/components/dialog.md
Disclosurecui-disclosurereferences/components/disclosure.md
Dividercui-dividerreferences/components/divider.md
Drawercui-drawerreferences/components/drawer.md
Feedback Buttonscui-feedback-buttonsreferences/components/feedback-buttons.md
Feedback for AIcui-feedback-for-aireferences/components/feedback-for-ai.md
Headercui-headerreferences/components/header.md
Iconcui-iconreferences/components/icon.md
Info Labelcui-info-labelreferences/components/info-label.md
Inputcui-inputreferences/components/input.md
Labelcui-labelreferences/components/label.md
Linkcui-linkreferences/components/link.md
Menucui-menureferences/components/menu.md
Menu Itemcui-menu-itemreferences/components/menu-item.md
Menu Listcui-menu-listreferences/components/menu-list.md
Message Barcui-message-barreferences/components/message-bar.md
Microfeedbackcui-microfeedbackreferences/components/microfeedback.md
Navigation Headingcui-nav-headingreferences/components/nav-heading.md
Navigation Itemcui-nav-itemreferences/components/nav-item.md
Overflowcui-overflowreferences/components/overflow.md
Paginationcui-paginationreferences/components/pagination.md
Personacui-personareferences/components/persona.md
Pop Overcui-pop-overreferences/components/pop-over.md
Profilecui-profilereferences/components/profile.md
Progress Barcui-progress-barreferences/components/progress-bar.md
Quick Navcui-quick-navreferences/components/quick-nav.md
Radiocui-radioreferences/components/radio.md
Radio Groupcui-radio-groupreferences/components/radio-group.md
Rich Text Editorcui-rich-text-editorreferences/components/rich-text-editor.md
Search Boxcui-search-boxreferences/components/search-box.md
Selectcui-selectreferences/components/select.md
Side Navigationcui-side-navreferences/components/side-nav.md
Skeletoncui-skeletonreferences/components/skeleton.md
Skip Tocui-skip-toreferences/components/skip-to.md
Slidercui-sliderreferences/components/slider.md
Spinnercui-spinnerreferences/components/spinner.md
Switchcui-switchreferences/components/switch.md
Tabcui-tabreferences/components/tab.md
Tab Panelcui-tab-panelreferences/components/tab-panel.md
Tablecui-tablereferences/components/table.md
Tabscui-tabsreferences/components/tabs.md
Tagcui-tagreferences/components/tag.md
Teaching Pop Overcui-teaching-pop-overreferences/components/teaching-pop-over.md
Text Areacui-text-areareferences/components/text-area.md
Toolbarcui-toolbarreferences/components/toolbar.md
Tooltipcui-tooltipreferences/components/tooltip.md
Top Navigationcui-top-navreferences/components/top-nav.md
Treecui-treereferences/components/tree.md
Uploadercui-uploaderreferences/components/uploader.md

Components in the manifest only (API-only — no design guidance doc yet):

ComponentTagManifest path
Button Group Overflowcui-button-group-overflowsrc/components/button-group-overflow/button-group-overflow.ts
Menu Groupcui-menu-groupsrc/components/menu-group/menu-group.ts
Push Panecui-push-panesrc/components/push-pane/push-pane.ts
Teaching Popovercui-teaching-popoversrc/components/teaching-popover/teaching-popover.ts
Tree Itemcui-tree-itemsrc/components/tree-item/tree-item.ts

Templates

Page-level layout patterns. Read before composing full pages.

Task Flows

Multi-step interaction patterns. Read when implementing these specific user flows.

UX Guides

Cross-cutting design guidance. Read when the topic is relevant.

Common Patterns

React Component Usage (default)

tsx
import { CuiButton } from '@charm-ux/cui/react';

export function SaveButton() {
  return <CuiButton appearance="primary">Save</CuiButton>;
}

Slots in React

Web component slots map to React props with the same name. Use the slot attribute on child elements:

tsx
import { CuiButton, CuiIcon } from '@charm-ux/cui/react';

export function AddItemButton() {
  return (
    <CuiButton>
      <CuiIcon slot="start" name="add" />
      Add item
    </CuiButton>
  );
}

Event Handling in React

Coherence React wrappers expose events as camelCase callback props. Use the onEventName pattern:

tsx
import { CuiDialog, CuiButton } from '@charm-ux/cui/react';
import { useRef } from 'react';

export function ConfirmDialog() {
  const dialogRef = useRef<HTMLElement>(null);

  return (
    <CuiDialog
      ref={dialogRef}
      heading="Confirm"
      onDialogRequestClose={(e) => {
        // Optionally prevent close: e.preventDefault();
      }}
    >
      <p>Are you sure?</p>
      <CuiButton slot="footer" appearance="primary">Yes</CuiButton>
      <CuiButton slot="footer">Cancel</CuiButton>
    </CuiDialog>
  );
}

Show/Hide with Triggers

tsx
import { CuiButton, CuiDrawer } from '@charm-ux/cui/react';

export function SettingsDrawer() {
  return (
    <>
      <CuiButton shows="my-drawer">Open Drawer</CuiButton>
      <CuiDrawer id="my-drawer" heading="Settings">
        <p>Drawer content</p>
      </CuiDrawer>
    </>
  );
}

CSS Custom Properties

Override component styling via CSS custom properties (same in React and HTML):

css
cui-button {
  --button-bg-color: var(--colorBrandBackground);
  --button-fg-color: var(--colorNeutralForegroundOnBrand);
  --button-border-radius: 8px;
}

Web Component Usage (alternate — only when explicitly requested)

html
<script type="module">
  import '@charm-ux/cui/dist/components/button/index.js';
</script>
<cui-button appearance="primary">Save</cui-button>

Accessibility Rules

Every component meets the Microsoft Accessibility Standards (MAS). When composing UIs:

  1. Use cui-skip-to as the first tab stop on every page
  2. Assign landmarks (<main>, <nav>, <header>) for skip-to navigation
  3. Every interactive element must have a keyboard-accessible equivalent
  4. All button text must pass 4.5:1 contrast; icons must pass 3:1
  5. Labels cannot be substituted with placeholder text
  6. Use aria-label or heading text for dialogs and drawers
  7. Read references/guides/accessibility.md for comprehensive guidance

Previewing Components

A Vite + React preview app is set up at coherence-preview/. Use it to render any generated .tsx component in the browser.

Quick Start

  1. Import the component in coherence-preview/src/main.tsx:
    tsx
    import '@charm-ux/cui/dist/themes/cui/theme.css';
    import '@charm-ux/cui/dist/themes/cui/reset.css';
    import MyComponent from '../../MyComponent';
    
  2. Start the dev server: cd coherence-preview && npx vite
  3. Open the URL printed by Vite (usually http://localhost:5173)

The theme CSS imports provide all Coherence design tokens. The @charm-ux/cui/react wrappers auto-register their underlying web component definitions on first render.

Adding New Components to Preview

Edit coherence-preview/src/main.tsx — replace or add the component import and render it inside the root <div>. Vite HMR will update the browser automatically.

Icons & Fluent 2 Dependency

The cui-icon component relies on the Fluent 2 icon set. Icons referenced by name attribute must be registered first.

Critical: Import the Project Config

When generating code that uses <cui-icon name="..."> (or <CuiIcon name="..."> in React), you must ensure the project configuration is imported. Without it, icons will show a fallback question-mark and log a console warning.

For web components / plain HTML:

js
import '@charm-ux/cui/dist/project-config.js';
import '@charm-ux/cui/dist/components/icon/index.js';

For React: No extra import needed — the @charm-ux/cui/react wrappers auto-register icons.

For the preview app (coherence-preview/): Add this import to main.tsx:

tsx
import '@charm-ux/cui/dist/project-config.js';

Available Icon Names

After importing the project config, ~80 Fluent 2 icons are available. Common ones include: add, alert, attach, bookmark, bot, calendar, chat, checkmark, clock, comment, copy-filled, dismiss-circle, document-edit, error-circle, eye-off, filter-filled, like-filled, lock-closed, more-horizontal, pin-filled, star-filled, zoom-in, zoom-out.

See references/components/icon.md for the full list and custom icon registration.

Mapping to charm-pilot

When working in the local charm-pilot codebase (@charm-ux/core):

Coherence (cui-*)charm-pilot (ch-*)
cui-buttonch-button
cui-dialogch-dialog
cui-inputch-input
......

The design guidance, slots, attributes, events, and CSS properties documented in the Coherence references apply to both. The ch-* components in charm-pilot are built following the same Coherence specifications.