Admin 元件

Tooltip

參考API
懸停時顯示輔助說明。

安裝

Terminal
pnpm dlx shadcn-vue add @admin/tooltip
import {  AdminTooltip,  AdminTooltipContent,  AdminTooltipProvider,  AdminTooltipTrigger,} from '@/components/admin/tooltip'

用法

<script setup lang="ts">import { AdminButton } from '@/components/admin/button'import {  AdminTooltip,  AdminTooltipContent,  AdminTooltipProvider,  AdminTooltipTrigger} from '@/components/admin/tooltip'</script>​<template>  <admin-tooltip-provider>    <admin-tooltip>      <admin-tooltip-trigger as-child>        <admin-button>Hover me</admin-button>      </admin-tooltip-trigger>      <admin-tooltip-content>Tooltip content</admin-tooltip-content>    </admin-tooltip>  </admin-tooltip-provider></template>

場景

四向擺放

<script setup lang="ts">import { AdminButton } from '@/components/admin/button'import {  AdminTooltip,  AdminTooltipContent,  AdminTooltipProvider,  AdminTooltipTrigger} from '@/components/admin/tooltip'</script>​<template>  <admin-tooltip-provider>    <div class="flex items-center gap-3">      <admin-tooltip>        <admin-tooltip-trigger as-child>          <admin-button size="small" variant="outline">Top</admin-button>        </admin-tooltip-trigger>        <admin-tooltip-content side="top">出現在上方</admin-tooltip-content>      </admin-tooltip>​      <admin-tooltip>        <admin-tooltip-trigger as-child>          <admin-button size="small" variant="outline">Right</admin-button>        </admin-tooltip-trigger>        <admin-tooltip-content side="right">出現在右方</admin-tooltip-content>      </admin-tooltip>​      <admin-tooltip>        <admin-tooltip-trigger as-child>          <admin-button size="small" variant="outline">Bottom</admin-button>        </admin-tooltip-trigger>        <admin-tooltip-content side="bottom">出現在下方</admin-tooltip-content>      </admin-tooltip>​      <admin-tooltip>        <admin-tooltip-trigger as-child>          <admin-button size="small" variant="outline">Left</admin-button>        </admin-tooltip-trigger>        <admin-tooltip-content side="left">出現在左方</admin-tooltip-content>      </admin-tooltip>    </div>  </admin-tooltip-provider></template>

富文字內容

<script setup lang="ts">import { AdminButton } from '@/components/admin/button'import {  AdminTooltip,  AdminTooltipContent,  AdminTooltipProvider,  AdminTooltipTrigger} from '@/components/admin/tooltip'</script>​<template>  <admin-tooltip-provider>    <admin-tooltip>      <admin-tooltip-trigger as-child>        <admin-button variant="outline">Hover for details</admin-button>      </admin-tooltip-trigger>      <admin-tooltip-content class="max-w-60">        <div class="flex flex-col gap-1">          <span class="typo-title-small">預約提示</span>          <span class="typo-caption-small">            預約成立後系統會寄送確認信,可在個人頁面查看與取消。          </span>        </div>      </admin-tooltip-content>    </admin-tooltip>  </admin-tooltip-provider></template>

API 參考

組成

<template>  <admin-tooltip-provider>    <admin-tooltip>      <admin-tooltip-trigger>觸發元素</admin-tooltip-trigger>      <admin-tooltip-content>說明文字</admin-tooltip-content>    </admin-tooltip>  </admin-tooltip-provider></template>

admin-tooltip-provider

Props

名稱型別預設值說明
delayDurationnumber | undefined0The duration from when the pointer enters the trigger until the tooltip gets opened.
skipDelayDurationnumber | undefined300How much time a user has to enter another trigger without incurring a delay again.
disableHoverableContentboolean | undefinedfalseWhen `true`, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.
disableClosingTriggerboolean | undefinedfalseWhen `true`, clicking on trigger will not close the content.
disabledboolean | undefinedfalseWhen `true`, disable tooltip
ignoreNonKeyboardFocusboolean | undefinedfalsePrevent 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.
contentTooltipContentProps | undefined—Default settings that will be used by all tooltip components.
classunknown——

Slots

名稱Bindings說明
default{}—

admin-tooltip

Props

名稱型別預設值說明
defaultOpenboolean | undefined—The open state of the tooltip when it is initially rendered. Use when you do not need to control its open state.
openboolean | undefined—The controlled open state of the tooltip.
delayDurationnumber | undefined700Override the duration given to the `Provider` to customise the open delay for a specific tooltip.
disableHoverableContentboolean | undefined—Prevents Tooltip.Content from remaining open when hovering. Disabling this has accessibility consequences. Inherits from Tooltip.Provider.
disableClosingTriggerboolean | undefinedfalseWhen `true`, clicking on trigger will not close the content.
disabledboolean | undefinedfalseWhen `true`, disable tooltip
ignoreNonKeyboardFocusboolean | undefinedfalsePrevent 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.
classunknown——

Events

名稱Payload說明
update:openboolean—

Slots

名稱Bindings說明
default{ open: boolean; }—

admin-tooltip-content

Props

名稱型別預設值說明
forceMountboolean | undefined—Used to force mounting when more control is needed. Useful when controlling animation with Vue animation libraries.
ariaLabelstring | undefinedStringBy 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.
asChildboolean | undefined—Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details.
asglobalThis.Component | AsTag | undefined"div"The element or component this component should render as. Can be overwritten by `asChild`.
align"start" | "end" | "center" | undefined"center"The preferred alignment against the trigger. May change when collisions occur.
sideOffsetnumber | undefined4The distance in pixels from the trigger.
side"top" | "right" | "bottom" | "left" | undefined"bottom"The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
alignOffsetnumber | undefined0An offset in pixels from the `start` or `end` alignment options.
avoidCollisionsboolean | undefinedtrueWhen `true`, overrides the side and align preferences to prevent collisions with boundary edges.
collisionBoundaryElement | (Element | null)[] | null | undefined[]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.
collisionPaddingnumber | Partial<Record<"top" | "right" | "bottom" | "left", number>> | undefined0The 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 }.
arrowPaddingnumber | undefined0The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners.
sticky"partial" | "always" | undefined"partial"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.
hideWhenDetachedboolean | undefinedfalseWhether to hide the content when the trigger becomes fully occluded.
positionStrategy"fixed" | "absolute" | undefined—The type of CSS position property to use.
updatePositionStrategy"always" | "optimized" | undefined'optimized'Strategy to update the position of the floating element on every animation frame.
classClassValue—根元素之自訂 class

Events

名稱Payload說明
escapeKeyDownKeyboardEvent—
pointerDownOutsideEvent—

Slots

名稱Bindings說明
default{}—

admin-tooltip-trigger

Props

名稱型別預設值說明
referenceReferenceElement | undefined—The reference (or anchor) element that is being referred to for positioning. If not provided will use the current component as anchor.
asChildboolean | undefined—Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details.
asglobalThis.Component | AsTag | undefined"div"The element or component this component should render as. Can be overwritten by `asChild`.
classunknown——

Slots

名稱Bindings說明
default{}—

更新紀錄

此元件尚無更新紀錄。