Quick start
A guide to install Vase UI and assemble your first component.
Install the package
Install Vase UI with a package manager:
pnpm add @vase-ui/vuenpm install @vase-ui/vueyarn add @vase-ui/vueThe package needs:
- Vue 3.5.46 or later.
vueis a peer dependency of the package. - A browser that has the web platform features that are Baseline Widely available.
- The global
Temporalfor the date and time components. Where the JavaScript engine does not have it, load a polyfill.
Each component has its own entry point, such as @vase-ui/vue/popover. The entry point @vase-ui/vue exports each component, except the date and time components. The package has no side effects, so a bundle holds only the components that your app imports.
In a Nuxt app, add the Nuxt module of the package. Your components then use each component with no import.
Set up
Portals
A component that renders a popup, such as Dialog or Popover, puts the popup in a portal. By default, the portal is in <body>, outside the root element of your app.
Give the root element the style isolation: isolate. In a Vue app, the root element is the element that createApp().mount() gets, such as #app. In a Nuxt app, it is #__nuxt.
#app {
isolation: isolate;
}#__nuxt {
isolation: isolate;
}The root element then has its own stacking context. A popup shows above the page, and a z-index inside the root element cannot put an element above the popup.
Assemble a component
This sample imports the Popover component, assembles its parts and styles them. Vase UI ships no styles, so you can use plain CSS, CSS Modules, Tailwind CSS or another tool.
<script setup lang="ts">
import { Popover } from '@vase-ui/vue/popover';
</script>
<template>
<Popover.Root>
<Popover.Trigger class="trigger">Notifications</Popover.Trigger>
<Popover.Portal>
<Popover.Positioner :side-offset="8">
<Popover.Popup class="popup">
<Popover.Arrow class="arrow" />
<Popover.Title class="title">Notifications</Popover.Title>
<Popover.Description class="description">You are all caught up.</Popover.Description>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>
</template>
<style scoped>
.trigger {
height: 2rem;
padding: 0 0.75rem;
border: 1px solid currentColor;
background-color: transparent;
color: inherit;
font: inherit;
font-size: 0.875rem;
}
.trigger[aria-expanded='true'] {
background-color: color-mix(in srgb, currentColor 10%, transparent);
}
.trigger:focus-visible {
outline: 2px solid currentColor;
outline-offset: 2px;
}
.popup {
--background: white;
position: relative;
width: 15rem;
padding: 0.75rem;
border: 1px solid;
background-color: var(--background);
color: black;
@media (prefers-color-scheme: dark) {
--background: black;
color: white;
}
}
.arrow {
width: 12px;
height: 6px;
overflow: clip;
&[data-side='top'] {
bottom: -6px;
rotate: 180deg;
}
&[data-side='bottom'] {
top: -6px;
}
&[data-side='left'] {
right: -9px;
rotate: 90deg;
}
&[data-side='right'] {
left: -9px;
rotate: -90deg;
}
&::before {
content: '';
position: absolute;
bottom: 0;
left: 50%;
box-sizing: border-box;
width: calc(6px * sqrt(2));
height: calc(6px * sqrt(2));
border: 1px solid;
background-color: var(--background);
transform: translate(-50%, 50%) rotate(45deg);
}
}
.title {
margin: 0;
font-size: 0.875rem;
font-weight: 700;
}
.description {
margin: 0;
font-size: 0.875rem;
}
</style>Next steps
The handbook shows how to style, animate and compose the components. Each component has its own page, such as the page of Popover. The parity page shows the state of each component against Base UI.