TDesign Mobile Vue 3 UI Library
TDesign Mobile Vue is a comprehensive UI component library specifically designed for Vue 3 and mobile web applications. Currently stable at version 1.13.2, the library maintains a frequent release cadence with regular minor and patch updates, often several per month, introducing new features, bug fixes, and performance enhancements. It is part of the broader TDesign enterprise design system, ensuring consistent API and UI/UX across various frameworks like React and WeChat MiniProgram. Key differentiators include its focus on mobile-first interactions, high-quality components, dark mode support, extensive theme customization options, and built-in tree-shaking support for optimized bundle sizes. It ships with TypeScript types for improved developer experience and type safety.
Common errors
-
Error: A component name can only contain alphanumeric characters or dashes, but got 't-ActionSheetPlugin'.
cause Attempting to use a functional API (like `ActionSheetPlugin`) as a Vue component in the template.fixFunctional APIs are typically called programmatically (e.g., `ActionSheetPlugin.show()`) and are not meant to be rendered directly as `<t-action-sheet-plugin>`. Use `<t-action-sheet>` for the component. -
Failed to resolve component: t-button. If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
cause TDesign components were not properly registered with the Vue application.fixEnsure you have `import TDesign from 'tdesign-mobile-vue';` and `app.use(TDesign);` in your main application entry file (e.g., `main.ts` or `main.js`). If using individual imports, make sure each component is imported and used correctly. -
Module not found: Error: Can't resolve 'tdesign-mobile-vue/es/style/index.css'
cause The main CSS file for TDesign Mobile Vue is missing or the import path is incorrect.fixVerify that `tdesign-mobile-vue` is correctly installed (`npm install tdesign-mobile-vue`) and ensure the import path `import 'tdesign-mobile-vue/es/style/index.css';` is correct for the global styles. For component-specific styles, check the documentation.
Warnings
- breaking The export method for `ActionSheet` was adjusted in v1.13.0. The component and its functional API are now separated.
- breaking In v1.11.0, several icons were removed from the `Icon` component (`video-camera-3`, `video-camera-3-filled`, `list`). New icons were also added.
- gotcha In v1.10.0, the `CheckboxGroup` component changed its behavior when `value` is `undefined`. It will no longer warn and instead implicitly convert the data to an `Array` upon user selection.
- gotcha The library primarily supports modern browsers. Ensure your target browser versions meet the minimum requirements (e.g., Edge >=97, Firefox >=96, Chrome >=96, Safari >=14.1).
Install
-
npm install tdesign-mobile-vue -
yarn add tdesign-mobile-vue -
pnpm add tdesign-mobile-vue
Imports
- TDesign
const TDesign = require('tdesign-mobile-vue');import TDesign from 'tdesign-mobile-vue';
- Button
import Button from 'tdesign-mobile-vue/lib/button';
import { Button } from 'tdesign-mobile-vue'; - ActionSheetPlugin
import { ActionSheet } from 'tdesign-mobile-vue'; // Then try to use as functionimport { ActionSheetPlugin } from 'tdesign-mobile-vue'; - types
import type { ButtonProps } from 'tdesign-mobile-vue';
Quickstart
import { createApp } from 'vue';
import TDesign, { Button, Toast } from 'tdesign-mobile-vue';
import 'tdesign-mobile-vue/es/style/index.css'; // Import global styles
const App = {
setup() {
const showToast = () => {
Toast.info('This is a toast message!');
};
return { showToast };
},
template: `
<div style="padding: 20px;">
<h1>TDesign Mobile Vue Quickstart</h1>
<t-button block @click="showToast">Show Toast</t-button>
<t-button block variant="outline" style="margin-top: 10px;">Outline Button</t-button>
<p style="margin-top: 20px; font-size: 14px; color: #666;">
This example demonstrates global registration, individual component usage, and a functional API.
</p>
</div>
`,
};
const app = createApp(App);
app.use(TDesign); // Globally registers all TDesign components
app.mount('#app');