Use a Button or any other component in the default slot of the Tooltip.
<template>
<NTooltip text="Open on GitHub">
<NButton label="Open" color="neutral" variant="subtle" />
</NTooltip>
</template>
App, que usa o componente TooltipProvider do Reka UI.Use a prop text para definir o conteúdo do Tooltip.
<template>
<NTooltip text="Open on GitHub">
<NButton label="Open" color="neutral" variant="subtle" />
</NTooltip>
</template>
Use a prop kbds para renderizar componentes Kbd no Tooltip.
<template>
<NTooltip text="Open on GitHub" :kbds="['meta', 'G']">
<NButton label="Open" color="neutral" variant="subtle" />
</NTooltip>
</template>
meta, que é exibida como ⌘ no macOS e Ctrl em outras plataformas.Use a prop delay-duration para alterar o atraso antes de o Tooltip aparecer. Por exemplo, você pode fazê-lo aparecer instantaneamente definindo-a como 0.
<template>
<NTooltip :delay-duration="0" text="Open on GitHub">
<NButton label="Open" color="neutral" variant="subtle" />
</NTooltip>
</template>
tooltip.delayDuration no componente App.Use a prop content para controlar como o conteúdo do Tooltip é renderizado, como seu align ou side, por exemplo.
tooltip.content no componente App.<template>
<NTooltip
:content="{
align: 'center',
side: 'bottom',
sideOffset: 8
}"
text="Open on GitHub"
>
<NButton label="Open" color="neutral" variant="subtle" />
</NTooltip>
</template>
Use a prop arrow para exibir uma seta no Tooltip.
<template>
<NTooltip arrow text="Open on GitHub">
<NButton label="Open" color="neutral" variant="subtle" />
</NTooltip>
</template>
Use a prop disabled para desabilitar o Tooltip.
<template>
<NTooltip disabled text="Open on GitHub">
<NButton label="Open" color="neutral" variant="subtle" />
</NTooltip>
</template>
Você pode controlar o estado de abertura usando a prop default-open ou a diretiva v-model:open.
defineShortcuts, você pode abrir e fechar o Tooltip pressionando O.Você pode fazer o Tooltip acompanhar o cursor ao passar o mouse sobre um elemento usando a prop reference:
| Prop | Default | Type |
|---|---|---|
text | stringThe text content of the tooltip. | |
kbds | (string | undefined)[] | KbdProps[]The keyboard keys to display in the tooltip. | |
content | { side: 'bottom', sideOffset: 8, collisionPadding: 8 } | TooltipContentProps & Partial<EmitsToProps<TooltipContentImplEmits>>The content of the tooltip. Inherits from the |
arrow | false | boolean | TooltipArrowProps Display an arrow alongside the tooltip.
|
portal | true | string | false | true | HTMLElementRender the tooltip in a portal. |
reference | Element | VirtualElementThe reference (or anchor) element that is being referred to for positioning. If not provided will use the current component as anchor. | |
defaultOpen | boolean The open state of the tooltip when it is initially rendered. Use when you do not need to control its open state. | |
open | boolean The controlled open state of the tooltip. | |
delayDuration | 700 | numberOverride the duration given to the |
disableHoverableContent | boolean Prevents Tooltip.Content from remaining open when hovering. Disabling this has accessibility consequences. Inherits from Tooltip.Provider. | |
disableClosingTrigger | false | boolean When |
disabled | false | boolean When |
ignoreNonKeyboardFocus | false | boolean Prevent the tooltip from opening if the focus did not come from
the keyboard by matching against the |
ui | { content?: SlotClass; arrow?: SlotClass; text?: SlotClass; kbds?: SlotClass; kbdsSize?: SlotClass; } |
| Slot | Type |
|---|---|
default | { open: boolean; } |
content | { ui: object; } |
| Event | Type |
|---|---|
update:open | [value: boolean] |
export default defineAppConfig({
ui: {
tooltip: {
slots: {
content: 'flex items-center gap-1 bg-default text-highlighted shadow-sm rounded-sm ring ring-default h-6 px-2.5 py-1 text-xs select-none data-[state=delayed-open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-tooltip-content-transform-origin) pointer-events-auto',
arrow: 'fill-default',
text: 'truncate',
kbds: "hidden lg:inline-flex items-center shrink-0 gap-0.5 not-first-of-type:before:content-['·'] not-first-of-type:before:me-0.5",
kbdsSize: 'sm'
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nitro/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
tooltip: {
slots: {
content: 'flex items-center gap-1 bg-default text-highlighted shadow-sm rounded-sm ring ring-default h-6 px-2.5 py-1 text-xs select-none data-[state=delayed-open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-tooltip-content-transform-origin) pointer-events-auto',
arrow: 'fill-default',
text: 'truncate',
kbds: "hidden lg:inline-flex items-center shrink-0 gap-0.5 not-first-of-type:before:content-['·'] not-first-of-type:before:me-0.5",
kbdsSize: 'sm'
}
}
}
})
]
})