Auto import
vael-ui/resolver is a resolver for unplugin-vue-components. Register it once, and you can use any vael-ui component in a template without importing it. It resolves components, not directives.
npm install -D unplugin-vue-componentsSetup
Add the resolver wherever unplugin-vue-components is already configured:
// vite.config.ts
import Components from 'unplugin-vue-components/vite'
import { VaelUiResolver } from 'vael-ui/resolver'
export default {
plugins: [
Components({ resolvers: [VaelUiResolver()] }),
// ...your other plugins, vue() included
],
}Write the tag, and the plugin adds the import at build time:
<template>
<Button variant="primary">Save</Button>
</template>
<script setup lang="ts">
// no import — unplugin-vue-components inserts it at build time
</script>Vapor
vael-ui ships two builds from the same source: the VDOM build and the Vapor build (vael-ui/vapor). The resolver imports from the VDOM build by default. Pass variant: 'vapor' to import from the Vapor build instead. The resolver imports every component from one build, so pick the one your app renders with.
VaelUiResolver({ variant: 'vapor' })In a Vapor template, unplugin-vue-components only finds components inside another component’s slot. Until it supports Vapor, import top-level ones by hand, such as <Toaster>, <DialogHost> and <ConfigProvider>.
One shared import, no /vapor subpath
Your editor’s auto-import may keep suggesting vael-ui instead of vael-ui/vapor. It’s a known TypeScript limitation when a package exports the same name from two entry points. To avoid it, set a vapor export condition instead of importing from the subpath. Every import … from 'vael-ui' then resolves to the Vapor build across the project, for components and composables alike, so auto-import can’t pick the wrong one. vael-ui/motion follows it too, so its vAnimate is the Vapor directive.
// vite.config.ts
import { defaultClientConditions, defaultServerConditions } from 'vite'
export default {
resolve: { conditions: [...defaultClientConditions, 'vapor'] },
ssr: { resolve: { conditions: [...defaultServerConditions, 'vapor'] } },
}Add vapor to Vite’s default conditions instead of replacing them. A bare ['vapor'] drops the defaults, and other packages can then load the wrong file. The ssr line does the same for server rendering.
// tsconfig.json
{
"compilerOptions": {
"customConditions": ["vapor"]
}
}CSS
No extra setup here. Every vael-ui component imports its own CSS, so resolving a component also loads its styles. Most unplugin-vue-components resolvers need a separate sideEffects entry for that.
Bundlers
unplugin-vue-components supports Vite, Webpack, Rollup, esbuild and Rspack. The resolver is a plain function, so it works the same with all of them.