Skip to content
Klarhimmel UI

Tooltip

npx shadcn add @klarhimmel/tooltip @klarhimmel/button

Examples

  • Basic

  • Open

  • Shortcut

DetailsAbout, usage, props and more

A short label for a control, shown on hover and keyboard focus. Built on Radix Tooltip.

When to use

  • Use for

    Naming an icon, or showing the shortcut for a control.

  • Not for

    Text people need to finish a task. Touch screens never show it.

  • Pairs with

    Icon button (built in), Kbd.

Preview

Hover or tab to a control. Escape hides the tip.

tooltip.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Button } from '@/components/klarhimmel/ui/button';
import { Tooltip } from '@/components/klarhimmel/ui/tooltip';

export default function Example() {
  return (
    <Theme theme="brand">
      <Tooltip content="Copy the booking link" shortcut="C">
        <Button variant="secondary">Copy</Button>
      </Tooltip>
    </Theme>
  );
}

Import

Import

import { Tooltip, TooltipProvider } from '@/components/klarhimmel/ui/tooltip';
Files
tooltip.tsx, button.tsx, in components/klarhimmel/ui/. With it: editing, kbd, theme, utils. npm: radix-ui.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Limit
Overlays render into the Theme root with position: fixed. A transform on an ancestor re-parents fixed (a dialog centres in the wrapper) and overflow: hidden clips menus. Render <Theme> at the app root, outside any transformed wrapper.

Props

PropTypeDefaultDescription
Tooltip.contentReactNoderequiredRequired. Keep it to a few words.
Tooltip.shortcutstring-A keyboard shortcut shown after the text.
Tooltip.side'top' | 'right' | 'bottom' | 'left''top'Where it opens; it flips to stay on screen.
Tooltip.delaynumber-Milliseconds before it opens on hover. Focus opens it at once.
Tooltip.defaultOpenboolean-Start open (docs and screenshots). It closes on Escape or when the pointer or focus has been and gone.
Tooltip.childrenReactNoderequiredThe single element that gets the tooltip. It must be focusable.
TooltipProvider.childrenReactNoderequiredRequired. One focusable element.
TooltipProvider.delaynumber500Milliseconds before it opens on hover. Focus opens it at once.

Accessibility

KeyDoes
TabFocusing the control shows the tooltip
EscapeHides the tooltip
HoverShows after a short delay