Installation
Installing Packages
To add Virgo UI to your project, use one of the following commands:
bashpnpm add @virgo-ui/vuepnpm add @virgo-ui/vuebashyarn add @virgo-ui/vueyarn add @virgo-ui/vuebashnpm install @virgo-ui/vuenpm install @virgo-ui/vueNext, integrate Virgo into your
main.tsas demonstrated below:jsimport { createApp } from 'vue' import App from './App.vue' import { virgo } from '@virgo-ui/vue' // Imports virgo styles, which include only transitions and a scroll-lock style import '@virgo-ui/vue/dist/style.css' // Applying `app.use(virgo)` to register the Virgo plugin createApp(App).use(virgo).mount('#app')import { createApp } from 'vue' import App from './App.vue' import { virgo } from '@virgo-ui/vue' // Imports virgo styles, which include only transitions and a scroll-lock style import '@virgo-ui/vue/dist/style.css' // Applying `app.use(virgo)` to register the Virgo plugin createApp(App).use(virgo).mount('#app')
You're now ready to incorporate Virgo components within your Vue files:
<template>
<virgo-button>
<tooltip text="Hello!" />
Hover Over Me
</virgo-button>
</template><template>
<virgo-button>
<tooltip text="Hello!" />
Hover Over Me
</virgo-button>
</template>NOTE
Explore the default designs on the Themes page. Also, ensure to review the theme documentation for comprehensive insights on themes. Note that this installation process doesn't include the specific configuration and designs presented in the documentation, meaning the components will remain unstyled.
Understanding the preference to not globally register components, here are alternative approaches:
Tree Shaking
Opt for an À la carte approach if global registration doesn't suit your project's needs.
Disable global registration of components by setting the
registerComponentsoption tofalsewhen initializing the Virgo plugin.diffimport { virgo } from '@virgo-ui/vue' createApp(App) - .use(virgo) + .use(virgo, { registerComponents: false }) .mount('#app')import { virgo } from '@virgo-ui/vue' createApp(App) - .use(virgo) + .use(virgo, { registerComponents: false }) .mount('#app')Subsequently, import the components you need individually from
@virgo-ui/vue.vue<script setup> import { Tooltip } from '@virgo-ui/vue' </script> <template> <virgo-button> <tooltip text="Hello!" /> Hover Over Me </virgo-button> </template><script setup> import { Tooltip } from '@virgo-ui/vue' </script> <template> <virgo-button> <tooltip text="Hello!" /> Hover Over Me </virgo-button> </template>
Auto Importing Components with Tree Shaking
unplugin-vue-components facilitates the automatic, on-demand import of components, allowing you to skip explicit import statements while still benefiting from tree shaking.
First, ensure the
registerComponentsoption is set tofalsein yourmain.tsif not already done.diffimport { virgo } from '@virgo-ui/vue' createApp(App) - .use(virgo) + .use(virgo, { registerComponents: false }) .mount('#app')import { virgo } from '@virgo-ui/vue' createApp(App) - .use(virgo) + .use(virgo, { registerComponents: false }) .mount('#app')Proceed to install
unplugin-vue-components:bashpnpm add -D unplugin-vue-componentspnpm add -D unplugin-vue-componentsbashyarn add -D unplugin-vue-componentsyarn add -D unplugin-vue-componentsbashnpm install --save-dev unplugin-vue-componentsnpm install --save-dev unplugin-vue-componentsConfigure
unplugin-vue-componentsin yourvite.config.ts:js// additional imports import Components from 'unplugin-vue-components/vite' import { VirgoResolver } from '@virgo-ui/vue' export default defineConfig({ plugins: [ // other plugins Components({ resolvers: [ VirgoResolver() ] }), ], // additional configurations })// additional imports import Components from 'unplugin-vue-components/vite' import { VirgoResolver } from '@virgo-ui/vue' export default defineConfig({ plugins: [ // other plugins Components({ resolvers: [ VirgoResolver() ] }), ], // additional configurations })Components can now be used directly in templates and will be automatically imported as needed.
vue<template> <virgo-button> <tooltip text="Hello!" /> Hover Over Me </virgo-button> </template><template> <virgo-button> <tooltip text="Hello!" /> Hover Over Me </virgo-button> </template>
Volar Support
For projects utilizing Volar, global component types can be specified by adding the following configuration to your jsconfig.json or tsconfig.json for TypeScript projects:
{
"compilerOptions": {
// other options...
"types": ["@virgo-ui/vue/volar"]
}
}{
"compilerOptions": {
// other options...
"types": ["@virgo-ui/vue/volar"]
}
}If you have a typescript project, you will have to configure the above in the tsconfig.json file.