Updated
Gliding Tooltip
NewCustomize
Top
Delay500ms
Duration0.28s
Offset8px
Installation
npx shadcn@latest add https://uibrik.com/r/gliding-tooltip.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/gliding-tooltip/gliding-tooltip.tsx"use client"; import { useCallback, useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type PointerEvent, type ReactNode, } from "react"; import { animate, motion, motionValue, useMotionValue, useReducedMotion, type AnimationPlaybackControls, type MotionValue, } from "motion/react"; import { cn } from "@/lib/utils"; // Gliding tooltip. Wrap a row of icon buttons and they share one tooltip that
Adds the files to
components/uibrik/gliding-tooltip and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/gliding-tooltip.Usage
import { GlidingTooltip } from "@/components/uibrik/gliding-tooltip/gliding-tooltip";<GlidingTooltip side="top" delay={500} duration={0.28} offset={8} highlight label="Navigation"> …</GlidingTooltip>Where to use Gliding Tooltip
Icon toolbars
Editor and canvas toolbars read as one control instead of a row of popping labels.
Pairs with Selection Toolbar
Docks and rails
Icon-only navigation names each item without a flicker between them.
Pairs with Floating Navbar
Shortcut hints
A data-shortcut on a button adds a key hint, teaching shortcuts as people browse.
Props
GlidingTooltip- side
- Type "top" | "bottom"
- "top"
- Which side of the row the tooltip sits on.
- delay
- Type number
- 500
- How long the pointer rests before the first tooltip shows. The next ones show at once.
- duration
- Type number
- 0.28
- How long the tooltip and highlight take to glide.
- offset
- Type number
- 8
- Gap between the button and the tooltip.
- highlight
- Type boolean
- true
- Glide a soft highlight behind the hovered button.
- children
- Type ReactNode
- –
- Buttons or links with an aria-label or data-tooltip. A data-shortcut adds a key hint.
- label
- Type string
- –
- Names the toolbar for screen readers.
- className
- Type string
- –
- Classes for the row, e.g. its fill, padding and gap.