### Stepper Component Theming Example Source: https://github.com/tencent/tdesign-common/blob/develop/docs/mobile/api/stepper.md Demonstrates different visual themes available for the Stepper component. This example is for Vue and showcases theme customization. ```vue ``` -------------------------------- ### Image Display Best Practices (Good/Bad Examples) in HTML Source: https://github.com/tencent/tdesign-common/blob/develop/docs/mobile/flutter_design/image.md This HTML snippet presents examples of recommended and discouraged practices for displaying images when they are purely for visual presentation and lack preview functionality. It highlights the importance of appropriate image sizing to ensure clarity and accessibility of information. ```html
``` -------------------------------- ### Basic Stepper Component Example Source: https://github.com/tencent/tdesign-common/blob/develop/docs/mobile/api/stepper.md Demonstrates the fundamental usage of the Stepper component for quantity adjustments. This example requires the TDesign Vue framework. ```vue ``` -------------------------------- ### Stepper Component Size Variants Example Source: https://github.com/tencent/tdesign-common/blob/develop/docs/mobile/api/stepper.md Presents various size options for the Stepper component, allowing adjustments to its visual dimensions. This example is for Vue. ```vue ``` -------------------------------- ### Typical Form Example Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/form.md Demonstrates a typical form structure with various input controls. It highlights how submit and reset buttons trigger events, and how instance methods can be used for submission and reset when buttons are absent. ```vue ``` -------------------------------- ### Form Alignment and Layout Examples Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/form.md Demonstrates different label alignment options (right, left, top) and layout configurations for form elements to suit various design needs. ```vue ``` -------------------------------- ### Loading Plugins Dynamically in ChatMarkdown (KaTeX) Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/chat-markdown.md Shows how to dynamically load plugins for the cherry-markdown engine used by ChatMarkdown. This example specifically demonstrates loading the KaTeX plugin for rendering mathematical formulas. ```vue ``` -------------------------------- ### Login Form Example Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/form.md A specialized form component designed for user authentication, typically including fields for username and password. ```vue ``` -------------------------------- ### Stepper Component with Min/Max Limits Source: https://github.com/tencent/tdesign-common/blob/develop/docs/mobile/api/stepper.md Illustrates how to configure minimum and maximum values for the Stepper component to control the range of adjustments. This example is for Vue. ```vue ``` -------------------------------- ### TDesign Common Project Directory Structure Source: https://github.com/tencent/tdesign-common/blob/develop/develop-install.md This Bash script illustrates the typical directory structure of the TDesign common project, showing output directories for different module formats (UMD, ESM, ES, CJS), component-specific files, and essential project files like LICENSE, CHANGELOG.md, README.md, and package.json. ```bash ├─ dist ## umd │ ├─ tdesign.js │ ├─ tdesign.js.map │ ├─ tdesign.min.js │ ├─ tdesign.min.js.map │ ├─ tdesign.css │ ├─ tdesign.css.map │ └─ tdesign.min.css ├─ esm ## esm │ ├─ button │ ├─ style │ └─ index.js │ ├─ button.js │ ├─ button.d.ts │ ├─ index.js │ └─ index.d.ts │ ├─ index.js │ └─ index.d.ts │ ├─ es ## es │ ├─ button │ ├─ style │ ├─ css.js │ ├─ index.css │ └─ index.js │ ├─ button.js │ ├─ button.d.ts │ ├─ index.js │ └─ index.d.ts │ ├─ index.js │ └─ index.d.ts │ ├─ lib ## es │ ├─ button │ ├─ button.js │ ├─ button.d.ts │ ├─ index.js │ └─ index.d.ts │ ├─ index.js │ └─ index.d.ts | ├─ ejs ## cjs │ ├─ button │ ├─ button.js │ ├─ button.d.ts │ ├─ index.js │ └─ index.d.ts │ ├─ index.js │ └─ index.d.ts │ ├─ LICENSE ├─ CHANGELOG.md ├─ README.md └─ package.json ``` -------------------------------- ### Disabled Stepper Component Example Source: https://github.com/tencent/tdesign-common/blob/develop/docs/mobile/api/stepper.md Shows how to disable the Stepper component, preventing any user interaction for quantity changes. This example is implemented in Vue. ```vue ``` -------------------------------- ### Disabled Form Item Example Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/form.md Demonstrates how to disable individual form items using the `disabled` attribute, preventing user interaction and input. ```vue ``` -------------------------------- ### Configure Tree Structure Table with EnhancedTable Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/table.en-US.md Demonstrates how to configure the EnhancedTable component for tree structure display. It highlights key properties like `childrenKey`, `indent`, `treeNodeColumnIndex`, `checkStrictly`, and `defaultExpandAll` for customizing tree behavior and appearance. ```javascript import EnhancedTable from 'tdesign-common/es/table/enhanced-table'; // Example configuration for tree structure const tableConfig = { tree: { childrenKey: 'list', // Define alias for child nodes indent: 20, // Set indentation distance treeNodeColumnIndex: 1, // Set column for tree operations checkStrictly: true, // Independent row selection defaultExpandAll: true // Expand all nodes by default } }; // Usage within a component ``` -------------------------------- ### Configure Global Settings and Internationalization with TDesign Source: https://context7.com/tencent/tdesign-common/llms.txt Demonstrates how to configure global settings such as CSS class prefixes, animation options, and component defaults. It also shows how to integrate different language locales for internationalization, providing examples for Chinese (zh_CN), English (en_US), and Japanese (ja_JP). This configuration is typically used with TDesign's ConfigProvider component in Vue or React. ```typescript import defaultConfig from '@tdesign/common/js/global-config/default-config'; import zhCN from '@tdesign/common/js/global-config/locale/zh_CN'; import enUS from '@tdesign/common/js/global-config/locale/en_US'; import jaJP from '@tdesign/common/js/global-config/locale/ja_JP'; // 默认配置结构 const globalConfig = { classPrefix: 't', animation: { include: ['ripple', 'expand', 'fade'], exclude: [], }, calendar: { firstDayOfWeek: 1, fillWithZero: true, }, dialog: { closeOnEscKeydown: true, closeOnOverlayClick: true, confirmBtnTheme: { default: 'primary', warning: 'primary', danger: 'primary', }, }, drawer: { closeOnEscKeydown: true, closeOnOverlayClick: true, size: 'small', }, table: { hideSortTips: false, size: 'medium', }, datePicker: { firstDayOfWeek: 1, }, ...defaultConfig, }; // 国际化配置示例(中文) const locale = { pagination: { itemsPerPage: '{size} 条/页', jumpTo: '跳至', page: '页', total: '共 {count} 条数据', }, dialog: { confirm: '确认', cancel: '取消', }, table: { empty: '暂无数据', loadingText: '正在加载中,请稍后', sortAscendingOperationText: '点击升序', sortDescendingOperationText: '点击降序', }, datePicker: { placeholder: { date: '请选择日期', month: '请选择月份' }, weekdays: ['一', '二', '三', '四', '五', '六', '日'], confirm: '确定', }, upload: { sizeLimitMessage: '文件大小不能超过 {sizeLimit}', triggerUploadText: { fileInput: '选择文件', reupload: '重新选择', uploading: '上传中', }, }, form: { errorMessage: { required: '${name}必填', max: '${name}字符长度不能超过 ${validate} 个字符', pattern: '请输入正确的${name}', }, }, ...zhCN, }; // 在 Vue/React 中使用 ConfigProvider // Vue: // React: ``` -------------------------------- ### BEM Structure Example Source: https://github.com/tencent/tdesign-common/blob/develop/css-naming.md Illustrates the standard BEM naming structure: prefix-block__element--modifier. This structure helps in organizing CSS classes for better maintainability and avoiding style conflicts. ```html
``` -------------------------------- ### Control Tree Node Expansion and Collapse Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/table.en-US.md Illustrates how to programmatically control the expansion and collapse of nodes in a tree structure table using TDesign's EnhancedTable component instance methods. This includes expanding all, collapsing all, and toggling individual nodes. ```javascript import EnhancedTable from 'tdesign-common/es/table/enhanced-table'; // Assuming 'enhancedTableRef' is a ref to the EnhancedTable component instance const enhancedTableRef = ref(null); // Expand all nodes const expandAllNodes = () => { enhancedTableRef.value?.expandAll(); }; // Collapse all nodes const collapseAllNodes = () => { enhancedTableRef.value?.foldAll(); }; // Toggle expansion of a specific node const toggleNodeExpansion = (nodeId) => { enhancedTableRef.value?.toggleExpandData(nodeId); }; // Refresh table data const refreshTableData = () => { enhancedTableRef.value?.resetData(); }; // Get tree node data const getTreeNodeData = (nodeId) => { return enhancedTableRef.value?.getTreeNode(nodeId); }; ``` -------------------------------- ### Form Reset Functionality Examples Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/form.md Illustrates different ways to reset form data: clearing all fields to empty, resetting to initial values, or selectively resetting specific fields using instance methods. ```vue ``` -------------------------------- ### Subscribe to Tool State Externally with useAgentState (React) Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/chat-engine.md Demonstrates how to use the `useAgentState` hook in a React component to subscribe to tool execution states. This allows external UI elements, like a global progress bar, to display real-time task progress and status updates pushed via `STATE_SNAPSHOT` and `STATE_DELTA` events. ```javascript import React from 'react'; import { useAgentState } from '@tdesign/agent-ui'; // Assuming this is the correct import path // External progress panel component const GlobalProgressBar: React.FC = () => { // Use useAgentState to subscribe to state const { stateMap, currentStateKey } = useAgentState(); /* Backend pushes state data via STATE_SNAPSHOT and STATE_DELTA events, simulated data as follows: // // STATE_SNAPSHOT (initial snapshot): // data: {"type":"STATE_SNAPSHOT","snapshot":{"task_xxx":{"progress":0,"message":"Preparing to plan...","items":[]}}} // // STATE_DELTA (incremental update, using JSON Patch format): // data: {"type":"STATE_DELTA","delta":[ // {"op":"replace","path":"/task_xxx/progress","value":20}, // {"op":"replace","path":"/task_xxx/message","value":"Analyzing destination information"}, // {"op":"replace","path":"/task_xxx/items","value":[{"label":"Analyzing destination information","status":"running"}]} // ]} */ // useAgentState automatically handles these events and merges snapshot and delta into stateMap // Get current task state const currentState = currentStateKey ? stateMap[currentStateKey] : null; // items array contains information for each task step // Each item includes: label (step name), status (state: running/completed/failed) const items = currentState?.items || []; const completedCount = items.filter((item: any) => item.status === 'completed').length; return (
Progress: {completedCount}/{items.length}
{items.map((item: any, index: any) => (
{item.label} - {item.status}
))}
); }; ``` -------------------------------- ### Custom Syntax Rendering (Footnotes) in ChatMarkdown Source: https://github.com/tencent/tdesign-common/blob/develop/docs/web/api/chat-markdown.md Demonstrates how to implement custom syntax rendering in ChatMarkdown using the `createSyntaxHook` mechanism from cherry-markdown. This example shows how to create custom footnote syntax. ```vue ```