Installation
Prerequisites
Before you begin, please ensure that your development environment meets the following requirements:
- Vue: >= 3.5.0
- Node.js: >= 18.0.0 (Latest LTS version recommended)
- Package Manager: Recommended: pnpm
For the full support contract, including browser support, SSR expectations, and Nuxt compatibility boundaries, see Compatibility and Support Boundaries.
Using a Package Manager
We recommend using a package manager to install YH-UI to benefit from full type support and build optimizations.
pnpm add @yh-ui/yh-uinpm install @yh-ui/yh-uiyarn add @yh-ui/yh-uiBrowser Usage
The current documentation is maintained around npm or pnpm installation in bundler-based projects. For browser projects, prefer integrating YH-UI through your build tool so that the package exports, styles, and types stay aligned with the published entries.
On-demand Import
YH-UI supports Tree Shaking out of the box. By importing components directly, build tools (like Vite or Webpack) will automatically exclude unused code.
<script setup lang="ts">
import { YhButton } from '@yh-ui/yh-ui'
</script>Automatic On-demand Import (Recommended)
With the help of plugins, you can use YH-UI components just like native HTML tags without manual import calls.
1. Install Plugins
pnpm add -D unplugin-vue-components2. Configure Vite
Register the resolver in vite.config.ts:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { YhUIResolver } from '@yh-ui/yh-ui/resolver'
export default defineConfig({
plugins: [
vue(),
Components({
resolvers: [YhUIResolver()]
})
]
})Note
YhUIResolver() now auto-injects the matching CSS files for each component by default, so pure CSS projects can use it without installing Sass.
TypeScript Support
If you are using TypeScript, no extra types entry is required for the published package. Import component or helper types from the public package exports when needed:
import type { ButtonProps } from '@yh-ui/yh-ui'