DocumentationAll ComponentsContact usChangelog

Using ZUI-Web with AI Assistants and MCP

It's possible to use our library either without a custom elements MCP or with it.
Since @zeiss/zui@3.20.0 we also ship our own skills and advanced AI documentation in the .ai folder. For older versions the Custom Elements MCP Server could improve the usage.

We encourage you to share your experiences (e.g. in dev-sync meetings or Teams channels), especially if you have additional recommendations that are useful for our library.


Using ZUI with AI – without CEM MCP

We recommend using the .ai folder from @zeiss/zui as the primary source of truth for AI agents (e.g. GitHub Copilot repo instructions, Claude projects, internal agents).

To make sure Copilot follows some basic rules while generating code, copy the ZUI-INSTRUCTIONS.md from the package into your application repository

# from your project root (example; adjust command for your shell)
mkdir -p .ai
cp -r node_modules/@zeiss/zui/.ai/ZUI-INSTRUCTIONS.md* .github/instructions

2. Install the skills (skills.sh)

If you want to use the provided skills you can either install them with the skills CLI (skills.sh), from the .ai folder:

# from your project root
npx skills add ./node_modules/@zeiss/zui/.ai/skills --full-depth

This makes skills like zui-suggest-components, zui-react-usage, zui-angular-usage, etc. available to your agents.

Or you can add them manually to your e.g .github/skills directory.

Using ZUI with MCP servers (CEM + Figma)

We additionally recommend MCP servers to improve the usage of ZUI-Web with LLMs and coding assistants.

Figma MCP

The Figma MCP server can be useful to quickly generate code from designs.
See the official documentation on how to set up the Figma MCP server.

CEM MCP

With Figma MCP alone(and without the skills and instructions), your LLM will not know any details about ZUI-Web components, which will result in hallucinated code using non-existing components.

Our first attempt to provide actual knowledge about ZUI-Web components, we used the CEM MCP tool:

  • It uses the custom-elements.json file that is part of ZUI-Web releases.
  • It extracts information about available components, their properties, attributes and events.
  • It provides this structured information to the LLMs.

Setup

Add this configuration to your MCP config (the configuration may depend on the actual AI tool you're using):

{
  "mcpServers": {
    "cem": {
      "type": "local",
      "command": "npx",
      "args": ["-y", "@pwrs/cem", "mcp", "--package", "./node_modules/@zeiss/zui"]
    }
  }
}

Notes:

  • Use at least version 0.9.3 of @pwrs/cem (earlier versions had issues when used via npm).
  • Adjust the --package option and point to the location of the ZUI-Web package. Typically, this is ./node_modules/@zeiss/zui but it may differ depending on your package manager or monorepo layout.

Once configured, you should be able to ask questions like:

  • “Which components are available in the @zeiss/zui web component library?”
  • “What properties and events does zui-button expose?”

The LLM should also be able to retrieve component information automatically when generating code.


Agents

Using agents with additional instructions on how to use ZUI-Web components can further improve the combination of:

  • Figma MCP
  • CEM MCP
  • The .ai docs and skills

Example agent for Angular usage:

# Custom Agent for Integrating Web Components

## Task Overview

You are a custom agent responsible for integrating web components effectively. Follow these structured steps to ensure accurate implementation and usage.

## Steps to Complete the Task

1. **Information Gathering**:
   - Always utilize the **CEM MCP** to gather comprehensive information about web components. This includes understanding their functionality and requirements.
   - Specifically, use **CEM MCP** to extract details regarding the component's **API**, **events**, and **properties**.

2. **Data Source Limitation**:
   - Rely solely on **CEM MCP** for information. Do not scan the workspace or use any other sources for gathering data.

3. **Understanding Types**:
   - Look for the **expandedType** field in the **CEM MCP** response to identify the types of properties and events associated with the web components.

4. **File Path Conversion**:
   - When referencing component source files from `custom-elements.json`, convert paths from `src/components/xyz.ts` to the corresponding relative path in `dist/components/xyz.js`. Use these relative paths to locate JavaScript files for examples and implementation details.

5. **Code Creation**:
   - Always refer to the examples in the source files to understand how to utilize the component and its API. Gather insights regarding expected behavior and usage patterns.

6. **Icon Slots**:
   - For components with icon slots, use **zui-icons** from the `@zeiss/zui-icons` package to fill these slots. Ensure that the icons are imported from the package in your code.

7. **Font Management**:
   - Font files can be found in the `public/fonts` folder, while related CSS font properties are located in `dist/styles/font`. The names of the font files match those defined in Figma, allowing you to find corresponding font files and CSS properties easily.
   - **Note**: It is not necessary to set fonts on the ZUI components.

8. **Design Tokens**:
   - Use the naming convention from Figma to find corresponding CSS properties and values for design tokens. For example, the Figma token `sys/light/bg/1st-default/enabled` translates to `--zui-semantic-sys--bg--1st-default--enabled` in CSS.

9. **Property Matching**:
   - When implementing a component from Figma, verify if the options/properties (e.g., Emphasis, Size, State) defined in Figma correspond to the properties of the ZUI component (e.g., `zui-button`'s emphasis property).
   - If there is a direct match, set the ZUI component property accordingly (e.g., `<zui-button emphasis="highlight">` if Figma Emphasis is `highlight`).
   - If a Figma property does not have a direct match in the ZUI component, print a note specifying which Figma property and ZUI property do not correspond.

10. **CSS Custom Properties**:
    - When a ZUI component provides a CSS custom property for a style (e.g., `--zui-button-width` for width), always use the custom property instead of direct CSS styles.
    - If no CSS custom property exists for a style (as verified in the component manifest), set the style using standard CSS (e.g., `style="width:360px;"`).

11. **API Verification**:
    - When asked about using ZUI components, always check their API and ensure correct usage according to the examples referenced in step 5.

12. **Component Usage**:
    - When implementing a Figma design with different components, try to find the matching ZUI component based on naming or the description of the component. If you are not sure about the component to use, ask for clarification or provide a note about the uncertainty.

Limitations

There are some limitations with the CEM MCP Server we encountered:

  1. Even though we provide the custom-elements.json file for a long time, the file may lack some information. For example, some properties might be missing due to limitations in the tools used to generate this file. As always with AI: please verify everything the LLM is doing.
  2. MCP and LLMs are still relatively new techniques, especially for more niche tools like @pwrs/cem. The ZUI-Web team has limited capacity to support these tools directly.