Tooltip NEW
Default Classes
import type { ComponentClasses } from '@/plugin'
import type { tooltipProps } from '@/components/tooltip/meta'
export const tooltipClasses: ComponentClasses<tooltipProps> = {
wrapper: 'z-[54]',
content: 'bg-[hsl(var(--virgo-tooltip-bg-color))] px-2 py-1 rounded-lg',
contentText: 'text-sm text-white text-center'
}
export type tooltipClassesValidKeys = keyof typeof tooltipClasses
import type { ComponentClasses } from '@/plugin'
import type { tooltipProps } from '@/components/tooltip/meta'
export const tooltipClasses: ComponentClasses<tooltipProps> = {
wrapper: 'z-[54]',
content: 'bg-[hsl(var(--virgo-tooltip-bg-color))] px-2 py-1 rounded-lg',
contentText: 'text-sm text-white text-center'
}
export type tooltipClassesValidKeys = keyof typeof tooltipClasses
Basic
Use tooltip
component's text
prop to show passed text in tooltip.
You can also use default
slot to render custom content.
TIP
While rendering custom content, You can use .virgo-tooltip-text
class to add default styles of tooltip text.
Trigger
To open menu on click use set trigger
prop to click
.
v-model support
tooltip
also support v-model
to show/hide tooltip.
Delay
You can delay showing and hiding of tooltip by setting delay
(show delay) and hideDelay
props.
delay
- DX focused prop name
As we regularly configure delay for showing tooltip only and not for hiding, we named prop for delaying tooltip delay
instead of showDelay
.
Transition
tooltip
also support transition. Default transition is slide-y
. Set it to available transition to use different transition. e.g. transition="fade"
.
To disable the transition you can set transition
prop to null
.
Placement
As tooltip
uses Floating UI, you can configure how tooltip is rendered.
To adjust the placement of tooltip, use placement
prop. This will get directly passed to Floating UI as show in their docs.
✨ Auto Placement
If there's not enough space to render the tooltip on given position then it will update the position according to available space.
Strategy
Set which positioning strategy to use to render the tooltip. This is also Floating UI option, for more details please read the official docs here.
Middleware
tooltip
has some middleware as default to render the tooltip content correctly. You can also customize the middleware you want.
In below demo we are not using any middleware so tooltip component won't behave like above tooltip contents. e.g. Flipping tooltip content if there's not enough space won't work.
middleware
prop accepts function that must return array of middleware. Please refer to the code snippet of this demo for function signature.
You can read more about middleware on their official docs.
API
Useful when used in the component config classes
option, to style it conditionally. Can be a string, object, or an array of string or/and object.
Disable class inheritance from the Virgo plugin classes config. Only for this component.
Show/Hide floating element base on v-model value
Persistence of floating element when clicked outside of reference element
Delay before showing floating element
Delay before hiding floating element
Transition to add while showing/hiding floating element
Strategy option from Floating UI
Text to render in tooltip