v2.1.8
/
  • Get Started
  • Components
  • Composables
  • Typography
  • GitHub
  • Layout
  • App
  • Container
  • Error
  • SidebarLayout
  • Element
  • Advice
  • Alert
  • Avatar
  • AvatarGroup
  • Badge
  • Banner
  • Button
  • Calendar
  • Card
  • Chip
  • Collapsible
  • Countdown
  • FieldGroup
  • Kbd
  • Progress
  • Separator
  • Skeleton
  • Form
  • Checkbox
  • CheckboxGroup
  • ColorPicker
  • FileUpload
  • Form
  • FormField
  • Input
  • InputDate
  • InputMenu
  • InputNumber
  • InputTags
  • InputTime
  • PinInput
  • RadioGroup
  • Range
  • Select
  • SelectMenu
  • Switch
  • Textarea
  • Data
  • Accordion
  • DescriptionList
  • Empty
  • Table
  • TableWrapper
  • Timeline
  • User
  • Navigation
  • Breadcrumb
  • CommandPalette
  • Link
  • NavigationMenu
  • Pagination
  • Stepper
  • Tabs
  • Overlay
  • ContextMenu
  • DropdownMenu
  • Modal
  • Popover
  • Slideover
  • Toast
  • Tooltip
  • Page
  • PageCard
  • PageColumns
  • PageGrid
  • PageLinks
  • PageList
  • Dashboard
  • DashboardGroup
  • DashboardSearch
  • DashboardSearchButton
  • AI Chat
  • soonChatMessage
  • soonChatMessages
  • soonChatPalette
  • soonChatPrompt
  • soonChatPromptSubmit
  • Content
  • ContentSearch
  • ContentSearchButton
  • ContentSurround
  • ContentToc
  • Color Mode
  • ColorModeAvatar
  • ColorModeButton
  • ColorModeImage
  • ColorModeSelect
  • ColorModeSwitch
  • i18n
  • LocaleSelect
  • b24icons
  • b24jssdk
Use our Nuxt starter
v2.1.8
  • Docs
  • Components
  • Composables
  • Typography

Tooltip

A small window that shows details when you move your mouse over an item.
GitHub
Demo
Nuxt UI
TooltipTooltip

Usage

Use a Button or any other component in the default slot of the Tooltip.

{
  "wait": "Loading client-side content..."
}
Make sure to wrap your app with the App component which uses the TooltipProvider component from Reka UI.
You can check the App component tooltip prop to see how to configure the Tooltip globally.

Text

Use the text prop to set the content of the Tooltip.

{
  "wait": "Loading client-side content..."
}

Kbds

Use the kbds prop to render Kbd components in the Tooltip.

{
  "wait": "Loading client-side content..."
}
You can use special keys like meta that displays as ⌘ on macOS and Ctrl on other platforms.

Delay

Use the delay-duration prop to change the delay before the Tooltip appears. For example, you can make it appear instantly by setting it to 0.

{
  "wait": "Loading client-side content..."
}
This can be configured globally through the tooltip.delayDuration option in the App component.

Content

Use the content prop to control how the Tooltip content is rendered, like its align or side for example.

{
  "wait": "Loading client-side content..."
}

Arrow

Use the arrow prop to display an arrow on the Tooltip.

{
  "wait": "Loading client-side content..."
}

Disabled

Use the disabled prop to disable the Tooltip.

{
  "wait": "Loading client-side content..."
}

Examples

Control open state

You can control the open state by using the default-open prop or the v-model:open directive.

{
  "wait": "Loading client-side content..."
}
In this example, leveraging defineShortcuts, you can toggle the Tooltip by pressing O.

With following cursor

You can make the Tooltip follow the cursor when hovering over an element using the reference prop:

Hover me
{
  "wait": "Loading client-side content..."
}

Help Icon

You can use the Icon and the Tooltip.

{
  "wait": "Loading client-side content..."
}

API

Props

Prop Default Type
text string

The text content of the tooltip.

kbds (string | undefined)[] | KbdProps[]

The keyboard keys to display in the tooltip.

  • as?: any

    The element or component this component should render as. Defaults to 'kbd'.

  • value?: string
  • accent?: "default" | "accent" | "less"

    Defaults to 'default'.

  • size?: "sm" | "md" | "lg"

    Defaults to 'md'.

  • class?: any
content{ side: 'bottom', sideOffset: 8, collisionPadding: 8 } TooltipContentProps & Partial<EmitsToProps<TooltipContentImplEmits>>

The content of the tooltip.

  • side?: "top" | "right" | "bottom" | "left"

    The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled. Defaults to "top".

  • sideOffset?: number

    The distance in pixels from the trigger. Defaults to 0.

  • align?: "end" | "start" | "center"

    The preferred alignment against the trigger. May change when collisions occur. Defaults to "center".

  • alignOffset?: number

    An offset in pixels from the start or end alignment options. Defaults to 0.

  • avoidCollisions?: boolean

    When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to true.

  • collisionBoundary?: Element | (Element | null)[] | null

    The element used as the collision boundary. By default this is the viewport, though you can provide additional element(s) to be included in this check. Defaults to [].

  • collisionPadding?: number | Partial<Record<"top" | "right" | "bottom" | "left", number>>

    The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }. Defaults to 0.

  • arrowPadding?: number

    The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.

  • sticky?: "partial" | "always"

    The sticky behavior on the align axis. partial will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".

  • hideWhenDetached?: boolean

    Whether to hide the content when the trigger becomes fully occluded. Defaults to false.

  • positionStrategy?: "absolute" | "fixed"

    The type of CSS position property to use.

  • updatePositionStrategy?: "always" | "optimized"

    Strategy to update the position of the floating element on every animation frame. Defaults to 'optimized'.

  • forceMount?: boolean

    Used to force mounting when more control is needed. Useful when controlling animation with Vue animation libraries.

  • ariaLabel?: string

    By default, screenreaders will announce the content inside the component. If this is not descriptive enough, or you have content that cannot be announced, use aria-label as a more descriptive label. Defaults to String.

  • onEscapeKeyDown?: ((event: KeyboardEvent) => void)
  • onPointerDownOutside?: ((event: Event) => void)
arrowtrueboolean | TooltipArrowProps

Display an arrow alongside the tooltip.

portaltrue string | false | true | HTMLElement

Render the tooltip in a portal.

reference Element | VirtualElement

The reference (or anchor) element that is being referred to for positioning.

If not provided will use the current component as anchor.

  • getBoundingClientRect: () => { x: number; y: number; width: number; height: number; top: number; right: number; bottom: number; left: number; }
  • getClientRects?: (() => DOMRectList | { x: number; y: number; width: number; height: number; top: number; right: number; bottom: number; left: number; }[])
  • contextElement?: Element
defaultOpenboolean

The open state of the tooltip when it is initially rendered. Use when you do not need to control its open state.

openboolean

The controlled open state of the tooltip.

delayDuration700 number

Override the duration given to the Provider to customise the open delay for a specific tooltip.

disableHoverableContentboolean

Prevents Tooltip.Content from remaining open when hovering. Disabling this has accessibility consequences. Inherits from Tooltip.Provider.

disableClosingTriggerfalseboolean

When true, clicking on trigger will not close the content.

disabledfalseboolean

When true, disable tooltip

ignoreNonKeyboardFocusfalseboolean

Prevent the tooltip from opening if the focus did not come from the keyboard by matching against the :focus-visible selector. This is useful if you want to avoid opening it when switching browser tabs or closing a dialog.

b24ui { content?: ClassNameValue; arrow?: ClassNameValue; text?: ClassNameValue; kbds?: ClassNameValue; kbdsSize?: ClassNameValue; kbdsAccent?: ClassNameValue; }

Slots

Slot Type
default{ open: boolean; }
content{ b24ui: object; }

Emits

Event Type
update:open[value: boolean]

Theme

app.config.ts
export default defineAppConfig({
  b24ui: {
    tooltip: {
      slots: {
        content: 'dark flex flex-row items-center justify-between gap-[5px] will-change-[opacity] min-h-[37px] shadow-xl/20 select-none motion-safe:data-[state=delayed-open]:animate-[scale-in_100ms_ease-out] motion-safe:data-[state=closed]:animate-[scale-out_100ms_ease-in] p-[10px] text-(length:--ui-font-size-sm)/(--ui-font-line-height-reset) font-[family-name:var(--ui-font-family-primary)] bg-(--ui-color-bg-content-primary)/80 text-(--ui-color-design-plain-na-focused-content) rounded-[calc(var(--popup-window-border-radius)-2px)] origin-(--reka-tooltip-content-transform-origin) pointer-events-auto',
        arrow: 'fill-(--ui-color-bg-content-primary)/80',
        text: 'text-pretty max-w-[200px] min-w-[100px]',
        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',
        kbdsAccent: 'default'
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'

export default defineConfig({
  plugins: [
    vue(),
    bitrix24UIPluginVite({
      b24ui: {
        tooltip: {
          slots: {
            content: 'dark flex flex-row items-center justify-between gap-[5px] will-change-[opacity] min-h-[37px] shadow-xl/20 select-none motion-safe:data-[state=delayed-open]:animate-[scale-in_100ms_ease-out] motion-safe:data-[state=closed]:animate-[scale-out_100ms_ease-in] p-[10px] text-(length:--ui-font-size-sm)/(--ui-font-line-height-reset) font-[family-name:var(--ui-font-family-primary)] bg-(--ui-color-bg-content-primary)/80 text-(--ui-color-design-plain-na-focused-content) rounded-[calc(var(--popup-window-border-radius)-2px)] origin-(--reka-tooltip-content-transform-origin) pointer-events-auto',
            arrow: 'fill-(--ui-color-bg-content-primary)/80',
            text: 'text-pretty max-w-[200px] min-w-[100px]',
            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',
            kbdsAccent: 'default'
          }
        }
      }
    })
  ]
})

Toast

A short message to offer information or feedback to the user.

PageCard

A pre-styled card component featuring a title, description, and optional link.

On this page

  • Usage
    • Text
    • Kbds
    • Delay
    • Content
    • Arrow
    • Disabled
  • Examples
    • Control open state
    • With following cursor
    • Help Icon
  • API
    • Props
    • Slots
    • Emits
  • Theme
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24