Vitral 0.2
Overlay

Tooltip

The v-tooltip directive: a hint shown on hover and on keyboard focus, which describes the element it sits on.

Import

main.ts
import { Tooltip } from '@vitral/vue';

Placement

Modifiers pick the side: `.top` (the default), `.bottom`, `.left`, `.right`.

<script setup lang="ts">import { Button, Tooltip as vTooltip } from '@vitral/vue';</script> <template>    <Button v-tooltip.bottom="'Save the document'" icon="download" aria-label="Save" severity="secondary" />    <Button v-tooltip="'Top is the default'" label="Top" severity="secondary" />    <Button v-tooltip.right="'On the right'" label="Right" severity="secondary" />    <Button v-tooltip.bottom="'Below'" label="Bottom" severity="secondary" />    <Button v-tooltip.left="'On the left'" label="Left" severity="secondary" /></template>

Options

An object sets the text, placement and delays, and can disable it.

<script setup lang="ts">import { Button, Tooltip as vTooltip } from '@vitral/vue';import { ref } from 'vue'; const enabled = ref(true);</script> <template>    <Button v-tooltip="{ value: 'Shown after half a second', showDelay: 500 }" label="Show delay" severity="secondary" />    <Button v-tooltip="{ value: 'Lingers for a second after you leave', hideDelay: 1000 }" label="Hide delay" severity="secondary" />    <Button        v-tooltip="{ value: 'Tooltips wrap at twenty rem so a long explanation stays readable instead of running across the whole window.', placement: 'bottom' }"        label="Long text"        severity="secondary"    />    <Button v-tooltip="{ value: 'Now you see me', disabled: !enabled }" :label="enabled ? 'Enabled' : 'Disabled'" severity="secondary" @click="enabled = !enabled" /></template>

On a field

Focus the box with Tab: the tooltip shows, and the input is described by it.

<script setup lang="ts">import { InputText, Tooltip as vTooltip } from '@vitral/vue';</script> <template>    <InputText v-tooltip.right="'Letters, digits and dashes'" aria-label="Username" placeholder="Username" /></template>