Material Component Dev logo

Material Component Dev

OrganizationPopular
bytedance
material-component-dev

FlowGram 物料组件开发指南 - 用于在 form-materials 包中创建新的物料组件

Overview

Publisherbytedance
Repositoryflowgram.ai
Skill namematerial-component-dev
Stars
8.5K
Forks
775
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by bytedance on GitHub. Read the source before you install it.

Installation

Install the Material Component Dev AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/bytedance/flowgram.ai/tree/main/.claude/skills/material-component-dev
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bytedance/flowgram.ai.git /tmp/flowgram.ai
mkdir -p .claude/skills
cp -r /tmp/flowgram.ai/.claude/skills/material-component-dev .claude/skills/material-component-dev
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Material Component Dev in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Material Component Dev on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Material Component Dev is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

FlowGram Material Component Development

概述

本 SKILL 用于指导在 FlowGram 项目的 @flowgram.ai/form-materials 包中创建新的物料组件。

核心原则

1. 组件位置

  • ✅ 在现有包中创建:直接在 packages/materials/form-materials/src/components/ 下创建组件目录
  • ❌ 不要单独拆包:不创建新的 npm 包,保持简洁

2. 代码质量

  • ✅ 使用 named export:所有导出使用 named export 提高 tree shake 性能
  • ❌ 不写单元测试:通过 Storybook 进行手动测试
  • ✅ 通过类型检查:必须通过 yarn ts-check
  • ✅ 符合代码规范:遵循项目 ESLint 规则

3. 物料设计

  • ✅ 保持精简:只保留必要的 props,不添加非核心功能配置项
  • ✅ 功能单一:一个物料只做一件事
  • ✅ 使用内部依赖:优先使用 FlowGram 内部的组件和类型

4. 技术栈

  • UI 组件库:@douyinfe/semi-ui
  • 代码编辑器:JsonCodeEditor, CodeEditor 等来自 ../code-editor
  • 类型定义:IJsonSchema 来自 @flowgram.ai/json-schema(不使用外部的 json-schema 包)
  • React:必须显式 import React 避免 UMD 全局引用错误

开发流程

Step 1: 规划组件结构

确定组件的:

  • 功能:组件要解决什么问题
  • Props 接口:只保留核心必需的 props
  • 命名:使用 PascalCase,清晰描述功能

Step 2: 创建目录结构

bash
mkdir -p packages/materials/form-materials/src/components/{组件名}/utils

典型结构:

packages/materials/form-materials/src/components/{组件名}/
├── index.tsx                 # 导出文件 (named export)
├── {组件名}.tsx              # 主组件
├── {辅助组件}.tsx            # 可选的辅助组件
└── utils/                    # 可选的工具函数
    └── *.ts

Step 3: 实现组件

3.1 工具函数(如需要)
typescript
// utils/helper.ts
/**
 * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
 * SPDX-License-Identifier: MIT
 */

export function helperFunction(input: string): Output {
  // 实现逻辑
}
3.2 辅助组件(如需要)
typescript
// modal.tsx
/**
 * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
 * SPDX-License-Identifier: MIT
 */

import React, { useState } from 'react';
import { Modal, Typography } from '@douyinfe/semi-ui';

interface ModalProps {
  visible: boolean;
  onClose: () => void;
  onConfirm: (data: SomeType) => void;
}

export function MyModal({ visible, onClose, onConfirm }: ModalProps) {
  // 实现
}
3.3 主组件
typescript
// my-component.tsx
/**
 * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
 * SPDX-License-Identifier: MIT
 */

import React, { useState } from 'react';
import { Button } from '@douyinfe/semi-ui';
import type { IJsonSchema } from '@flowgram.ai/json-schema';

export interface MyComponentProps {
  /** 核心功能的回调 */
  onSomething?: (data: SomeType) => void;
}

// 使用 named export,不使用 default export
export function MyComponent({ onSomething }: MyComponentProps) {
  const [visible, setVisible] = useState(false);

  return (
    <>
      <Button onClick={() => setVisible(true)}>
        操作文本
      </Button>
      {/* 其他组件 */}
    </>
  );
}

关键点:

  • ✅ 显式 import React
  • ✅ 使用 Semi UI 组件
  • ✅ 使用 function 声明而非 React.FC
  • ✅ Props 精简,只保留核心功能
  • ✅ Named export
3.4 导出文件
typescript
// index.tsx
/**
 * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
 * SPDX-License-Identifier: MIT
 */

export { MyComponent } from './my-component';
export type { MyComponentProps } from './my-component';

Step 4: 在 form-materials 主入口导出

编辑 packages/materials/form-materials/src/components/index.ts:

typescript
export {
  // ... 其他组件按字母序
  MyComponent,
  // ... 继续其他组件
  type MyComponentProps,
  // ... 继续其他类型
} from './components';

然后编辑 packages/materials/form-materials/src/index.ts,确保新组件在主导出列表中:

typescript
export {
  // ... 其他组件按字母序
  MyComponent,
  // ...
  type MyComponentProps,
  // ...
} from './components';

Step 5: 创建 Storybook Story

在 apps/demo-materials/src/stories/components/ 创建 Story:

typescript
// my-component.stories.tsx
/**
 * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
 * SPDX-License-Identifier: MIT
 */

import React, { useState } from 'react';
import type { Meta, StoryObj } from 'storybook-react-rsbuild';
import { MyComponent } from '@flowgram.ai/form-materials';
import type { SomeType } from '@flowgram.ai/json-schema';

const MyComponentDemo: React.FC = () => {
  const [result, setResult] = useState<SomeType | null>(null);

  return (
    <div style={{ padding: '20px' }}>
      <h2>My Component Demo</h2>
      <MyComponent
        onSomething={(data) => {
          console.log('Generated data:', data);
          setResult(data);
        }}
      />

      {result && (
        <div style={{ marginTop: '20px' }}>
          <h3>结果:</h3>
          <pre style={{
            background: '#f5f5f5',
            padding: '16px',
            borderRadius: '4px',
            overflow: 'auto'
          }}>
            {JSON.stringify(result, null, 2)}
          </pre>
        </div>
      )}
    </div>
  );
};

const meta: Meta<typeof MyComponentDemo> = {
  title: 'Form Components/MyComponent',
  component: MyComponentDemo,
  parameters: {
    layout: 'centered',
    docs: {
      description: {
        component: '组件功能描述',
      },
    },
  },
  tags: ['autodocs'],
};

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {};

Step 6: 运行类型检查

bash
cd packages/materials/form-materials
yarn ts-check

确保通过所有类型检查。

Step 7: 启动开发环境测试

开启两个 Terminal:

Terminal 1 - 监听包编译:

bash
rush build:watch

Terminal 2 - 启动 Storybook:

bash
cd apps/demo-materials
yarn dev

访问 http://localhost:6006/,找到你的组件进行测试。

常见问题

Q1: React 引用错误

错误信息:

error TS2686: 'React' refers to a UMD global, but the current file is a module.

解决方案: 在文件顶部添加:

typescript
import React from 'react';

Q2: 组件未导出

错误信息:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

解决方案: 检查以下文件的导出:

  1. components/{组件名}/index.tsx
  2. components/index.ts
  3. src/index.ts

Q3: 类型找不到

错误信息:

Cannot find module '@flowgram.ai/json-schema' or its corresponding type declarations.

解决方案:

  • 使用 type IJsonSchema 而非 type JSONSchema7
  • 从 @flowgram.ai/json-schema 导入而非 json-schema

Q4: CodeEditor 没有 height 属性

错误信息:

Property 'height' does not exist on type 'CodeEditorPropsType'.

解决方案: 使用外层 div 设置高度:

tsx
<div style={{ minHeight: 300 }}>
  <JsonCodeEditor value={value} onChange={onChange} />
</div>

验收标准

  • 组件在 packages/materials/form-materials/src/components/ 下创建
  • 使用 named export
  • 通过 yarn ts-check 类型检查
  • Props 精简,只保留核心功能
  • 在 Storybook 中可以正常显示和使用
  • 功能正常,无明显 bug
  • 代码符合 FlowGram 代码规范

最佳实践

1. 组件设计

  • 单一职责:一个组件只做一件事
  • Props 精简:避免过度配置
  • 命名清晰:组件名和 Props 名要清晰易懂

2. 代码风格

  • 使用 TypeScript:充分利用类型系统
  • 显式导入:明确导入所需的依赖
  • 注释适度:关键逻辑添加注释

3. UI 一致性

  • 使用 Semi UI:保持 UI 风格一致
  • 响应式设计:考虑不同屏幕尺寸
  • 错误处理:友好的错误提示

4. 性能优化

  • Named export:支持 tree shaking
  • 按需加载:避免不必要的依赖
  • 合理使用 memo:必要时使用 React.memo

示例参考

完整示例请参考:

  • packages/materials/form-materials/src/components/json-schema-creator/
  • apps/demo-materials/src/stories/components/json-schema-creator.stories.tsx

Frequently asked questions

What does the Material Component Dev AI skill do?

FlowGram 物料组件开发指南 - 用于在 form-materials 包中创建新的物料组件

Why use Material Component Dev on TypingMind?

Because you install it once and use it with any model. Material Component Dev is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Material Component Dev in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/bytedance/flowgram.ai/tree/main/.claude/skills/material-component-dev. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Material Component Dev?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Material Component Dev?

As many as you like. As long as a model supports skills, you can use Material Component Dev with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Material Component Dev AI skill free?

Yes. It is published on GitHub by bytedance under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇