This document provides a high-level introduction to the tdesign-react repository, a React UI component library for desktop applications maintained by Tencent's TDesign team. The repository is structured as a pnpm monorepo that produces multiple build artifacts for different consumption patterns, supports comprehensive testing strategies, and includes an integrated documentation site.
Scope: This page covers the overall repository architecture, package organization, build system, and development infrastructure. For detailed information about specific subsystems, see:
Sources: README.md1-106 README-zh_CN.md1-106 CONTRIBUTING.md1-207
tdesign-react is a production-grade React component library with the following characteristics:
| Attribute | Value |
|---|---|
| Package Name | tdesign-react |
| Current Version | 1.15.9 |
| License | MIT |
| React Support | >=16.13.1 (peer dependency) |
| Package Manager | pnpm 9.15.9 |
| Repository Type | Monorepo workspace |
Core Features:
Sources: packages/tdesign-react/package.json1-98 README.md28-35 package.json2-56
Diagram: Monorepo Package Relationships and Data Flow
The repository follows a three-package architecture:
packages/components/ - Component implementations with co-located tests and examplespackages/common/ - Git submodule containing shared styles, tokens, and documentation structurepackages/tdesign-react/ - Build entry point and NPM package configurationSources: CONTRIBUTING.md38-59 package.json137-144 packages/tdesign-react/package.json1-20
Diagram: Critical File Paths for Development and Distribution
Component Organization Pattern:
Each component follows this structure within packages/components/:
component-name/
├── ComponentName.tsx # Main implementation
├── type.ts # TypeScript interfaces
├── _example/ # Demo examples
│ ├── base.tsx
│ └── advanced.tsx
├── __tests__/ # Unit tests
│ └── vitest-component.test.tsx
└── style/ # Component-specific styles (if any)
Sources: CONTRIBUTING.md50-59 packages/components/upload/themes/DraggerFile.tsx1-175
The published tdesign-react package exposes five distinct entry points for different module systems:
| Field | Path | Purpose |
|---|---|---|
main | lib/index.js | CommonJS for Node.js |
module | es/index.js | ES Modules for bundlers |
typings | es/index.d.ts | TypeScript definitions |
unpkg | dist/tdesign.min.js | CDN (UMD) via unpkg.com |
jsdelivr | dist/tdesign.min.js | CDN (UMD) via jsdelivr.com |
Side Effects Configuration: The package declares side effects for specific paths to ensure correct tree-shaking:
Sources: packages/tdesign-react/package.json5-29 README.md64-65
The build process uses a dual-track approach:
dist/tdesign.min.js])Build Scripts from package.json25-31:
Build Configuration Files:
script/rollup.config.js (referenced in package.json26)tsconfig.build.json (referenced in package.json28-31)Sources: package.json25-31 packages/tdesign-react/package.json41-47 CONTRIBUTING.md135-149
Diagram: Developer Command Flow and Interactions
Key Development Ports:
http://localhost:15000 (packages/tdesign-react/site/vite.config.js51)/react/components/{component-name}/react/demos/{component}/{demo-name}Special Route for Demo Debugging:
The Demo.jsx component (packages/tdesign-react/site/src/components/Demo.jsx1-100) provides isolated demo rendering at /react/demos/:component/:demo, enabling focused debugging without loading the full documentation page.
Sources: package.json5-35 CONTRIBUTING.md13-36 packages/tdesign-react/site/vite.config.js49-57 packages/tdesign-react/site/src/components/Demo.jsx64-99
The repository implements three parallel testing strategies:
| Test Type | Tool | Environment | Purpose |
|---|---|---|---|
| Unit Tests | Vitest | happy-dom | Component logic and rendering |
| SSR Tests | Vitest | Node.js | Server-side rendering validation |
| E2E Tests | Cypress | Real browser | Integration testing |
Test Execution Commands from package.json19-24:
Snapshot Test Strategy:
test/snap/__snapshots__/csr.test.jsx.snap (231KB, ~50 components)test/snap/__snapshots__/ssr.test.jsx.snap (158KB, ~50 components)These snapshots validate the HTML output of every component example, ensuring UI consistency across changes.
Sources: package.json19-24 test/snap/__snapshots__/csr.test.jsx.snap1-100 test/snap/__snapshots__/ssr.test.jsx.snap1-50
Diagram: Documentation Site Routing and Component Hierarchy
Key Site Files:
import.meta.glob() for dynamic demo loadingTDoc Components (from @tdesign/site-components):
<td-doc-layout> - Main layout wrapper<td-header> - Top navigation with framework selector<td-doc-aside> - Sidebar navigation<td-doc-content> - Markdown content renderer<td-doc-search> - Algolia-powered searchSources: packages/tdesign-react/site/src/App.jsx1-156 packages/tdesign-react/site/src/components/Demo.jsx1-100 packages/tdesign-react/site/vite.config.js1-63
The component library integrates with a separate icon package (tdesign-icons-react) that provides 2100+ icons:
Icon Consumption Patterns:
Icon Features (from v0.6.1+):
Version Dependency: packages/tdesign-react/package.json94 specifies "tdesign-icons-react": "^0.6.1"
Sources: packages/tdesign-react/package.json94 packages/components/icon/icon.en-US.md1-50 packages/components/icon/_example/IconExample.tsx1-51
ESLint Configuration (.eslintrc.js1-88):
airbnb-base, prettier, plugin:react/recommended@typescript-eslint/parser@typescript-eslint, react-hooksreact-hooks/rules-of-hooks: errorreact-hooks/exhaustive-deps: warn@typescript-eslint/no-unused-vars: errorimport/order: errorLint Staged (package.json42-46):
Commit Conventions:
cz-conventional-changelog (package.json38-40)husky git hooks (package.json35)Sources: .eslintrc.js1-88 package.json37-46 CONTRIBUTING.md186-193
The packages/common/ directory is a git submodule pointing to the tdesign-common repository:
Initialization: pnpm run init executes:
Submodule Contents:
style/web/ - Shared CSS and design tokensdocs/web/api/ - Component API documentation structurejs/ - Framework-agnostic utility functionsDevelopment Workflow with Submodule:
tdesign-common separatelytdesign-commonSources: CONTRIBUTING.md113-144 package.json7 CONTRIBUTING.md6-10
| Browser | Minimum Version |
|---|---|
| Chrome | 84+ |
| Firefox | 83+ |
| Edge | 84+ |
| Safari | 14.1+ |
The library does not support Internet Explorer. SSR compatibility is validated through dedicated test suites.
Sources: README.md71-77 test/snap/__snapshots__/ssr.test.jsx.snap1-50
Required Peer Dependencies (packages/tdesign-react/package.json67-70):
React 19 Support:
The library includes a React 19 adapter at es/_util/react-19-adapter.js (packages/tdesign-react/package.json26) for forward compatibility.
Related TDesign Libraries:
tdesign-vue-next - Vue 3.x implementationtdesign-vue - Vue 2.x implementationtdesign-miniprogram - WeChat mini-program componentsSources: packages/tdesign-react/package.json67-70 README.md79-86 packages/tdesign-react/CHANGELOG.md259
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.