Tooltip VTooltip displays a short description on hover or focus. Its content must remain non-interactive.
Usage Copy Copy to the clipboard
<script setup lang="ts">
import { VButton, VTooltip } from 'vectis-ui'
</script>
<template>
<VTooltip text="Copy to the clipboard">
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps">Copy</VButton>
</template>
</VTooltip>
</template> Examples Placements placement sets the preferred tooltip position.
top Placed top
top-start Placed top-start
top-end Placed top-end
bottom Placed bottom
bottom-start Placed bottom-start
bottom-end Placed bottom-end
left Placed left
right Placed right
<script setup lang="ts">
import { VButton, VTooltip, type TooltipPlacement } from 'vectis-ui'
const placements: TooltipPlacement[] = [
'top',
'top-start',
'top-end',
'bottom',
'bottom-start',
'bottom-end',
'left',
'right',
]
</script>
<template>
<div class="row">
<VTooltip
v-for="placement in placements"
:key="placement"
:text="`Placed ${placement}`"
:placement="placement"
>
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps">{{ placement }}</VButton>
</template>
</VTooltip>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-6) var(--vectis-space-4);
padding-block: var(--vectis-space-8);
}
</style> At the edge of the screen The tooltip moves to the opposite side when space is insufficient.
Prefers the top Asks for the top, takes the bottom near the edge
Prefers the bottom Asks for the bottom, takes the top near the edge
<script setup lang="ts">
import { VButton, VTooltip } from 'vectis-ui'
</script>
<template>
<!-- Scroll the triggers near the viewport edges to observe placement flipping. -->
<div class="demo">
<VTooltip text="Asks for the top, takes the bottom near the edge" placement="top">
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps"> Prefers the top </VButton>
</template>
</VTooltip>
<VTooltip text="Asks for the bottom, takes the top near the edge" placement="bottom">
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps">
Prefers the bottom
</VButton>
</template>
</VTooltip>
</div>
</template>
<style scoped>
.demo {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-4);
}
</style> Opening and closing openDelay sets the hover wait in milliseconds, closeDelay how long the tooltip stays once the pointer leaves. Focus opens immediately; Escape or trigger activation closes without moving focus.
300ms Appears after the default wait
800ms Appears after a longer wait
No wait Appears at once
<script setup lang="ts">
import { VButton, VTooltip } from 'vectis-ui'
</script>
<template>
<div class="demo">
<VTooltip text="Appears after the default wait">
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps">300ms</VButton>
</template>
</VTooltip>
<VTooltip text="Appears after a longer wait" :open-delay="800">
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps">800ms</VButton>
</template>
</VTooltip>
<VTooltip text="Appears at once" :open-delay="0">
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps">No wait</VButton>
</template>
</VTooltip>
</div>
</template>
<style scoped>
.demo {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-4);
}
</style> Describing, not naming The tooltip uses aria-describedby; the trigger still needs its own accessible name. Taps do not open it, so keep essential information available elsewhere.
Search everything
Export the current view as a CSV file
Discard the draft
<script setup lang="ts">
import { VIconButton, VTooltip } from 'vectis-ui'
import { close, description, search } from 'vectis-ui/icons'
</script>
<template>
<div class="demo">
<VTooltip text="Search everything">
<template #default="{ triggerProps }">
<VIconButton
v-bind="triggerProps"
:icon="search"
label="Search"
variant="outline"
tone="neutral"
/>
</template>
</VTooltip>
<VTooltip text="Export the current view as a CSV file">
<template #default="{ triggerProps }">
<VIconButton
v-bind="triggerProps"
:icon="description"
label="Export"
variant="outline"
tone="neutral"
/>
</template>
</VTooltip>
<!-- Keep essential information available outside tooltips for touch users. -->
<VTooltip text="Discard the draft">
<template #default="{ triggerProps }">
<VIconButton
v-bind="triggerProps"
:icon="close"
label="Discard"
variant="outline"
tone="danger"
/>
</template>
</VTooltip>
</div>
</template>
<style scoped>
.demo {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-4);
}
</style> Rich content content overrides text. Use formatting or decorative icons, without interactive controls.
<script setup lang="ts">
import { VButton, VHotkeys, VTooltip, VTypography } from 'vectis-ui'
</script>
<template>
<VTooltip placement="bottom-start">
<template #default="{ triggerProps }">
<VButton variant="outline" tone="neutral" v-bind="triggerProps">Search</VButton>
</template>
<template #content>
<div class="content">
<VTypography variant="label" as="strong">Global search</VTypography>
<span>Looks through projects, files and people.</span>
<span class="shortcut">
Shortcut
<VHotkeys keys="mod+k" variant="outline" />
</span>
</div>
</template>
</VTooltip>
</template>
<style scoped>
.content {
display: grid;
gap: var(--vectis-space-1);
padding-block: var(--vectis-space-1);
}
.shortcut {
display: flex;
align-items: center;
gap: var(--vectis-space-2);
}
</style> API Props Slots Types Types used in the API tables. Import exported types from vectis-ui.
CSS variables