Skip to main content

UI Tooltip System

Added: March 27, 2026 (PR #1102)
Location: packages/client/src/ui/core/tooltip/tooltipStyles.ts

Overview

The UI tooltip system provides centralized, consistent tooltip styling across all game panels. It eliminates ~500 lines of duplicated styling code and ensures visual hierarchy and readability across inventory, equipment, bank, spells, prayer, skills, trade, store, and loot panels.

Core Functions

getTooltipTitleStyle(theme, accentColor?)

Returns styling for tooltip title text. Parameters:
  • theme: Theme - Current theme object
  • accentColor?: string - Optional accent color (defaults to theme.colors.accent.secondary)
Returns: React.CSSProperties Example:
Output Style:

getTooltipMetaStyle(theme)

Returns styling for metadata/secondary text (e.g., item type, level requirements). Parameters:
  • theme: Theme - Current theme object
Returns: React.CSSProperties Example:
Output Style:

getTooltipBodyStyle(theme)

Returns styling for body content text (e.g., descriptions, stats). Parameters:
  • theme: Theme - Current theme object
Returns: React.CSSProperties Example:
Output Style:

getTooltipDividerStyle(theme, accentColor?)

Returns styling for section dividers within tooltips. Parameters:
  • theme: Theme - Current theme object
  • accentColor?: string - Optional accent color for border (defaults to theme.colors.border.default)
Returns: React.CSSProperties Example:
Output Style:

getTooltipTagStyle(theme)

Returns styling for tag/badge elements (e.g., item categories, skill types). Parameters:
  • theme: Theme - Current theme object
Returns: React.CSSProperties Example:
Output Style:

getTooltipStatusStyle(theme, tone)

Returns styling for status indicators (success/danger/warning/default). Parameters:
  • theme: Theme - Current theme object
  • tone: 'default' | 'success' | 'danger' | 'warning' - Status tone
Returns: React.CSSProperties Example:
Output Style (varies by tone):
Tone Colors:
  • success: Green background/border/text
  • danger: Red background/border/text
  • warning: Yellow/orange background/border/text
  • default: Accent color background/border/text

Usage Patterns

Basic Tooltip

Equipment Tooltip with Bonuses

Spell Tooltip with Rune Cost


Panels Using Tooltip System

The following panels have been updated to use the centralized tooltip system:
  1. InventoryPanel - Item tooltips with bonuses and descriptions
  2. EquipmentPanel - Equipment slot tooltips with stats and requirements
  3. BankPanel - Bank item tooltips with tab info and value
  4. SpellsPanel - Spell tooltips with rune costs and effects
  5. PrayerPanel - Prayer tooltips with drain rates and requirements
  6. SkillsPanel - Skill tooltips with XP progress and level info
  7. TradePanel - Trade item tooltips with quantities
  8. StorePanel - Store item tooltips with prices and stock
  9. LootWindowPanel - Loot item tooltips with item types
  10. ActionBarPanel - Action bar slot tooltips with shortcuts
  11. DuelPanel - Duel stake tooltips with item info

Migration Guide

Before (Duplicated Styles)

After (Centralized Utilities)


Design Principles

  1. Consistency: All tooltips use the same visual hierarchy
  2. Theming: Styles adapt to current theme (Hyperscape, Dark, Light)
  3. Accessibility: Clear text hierarchy with appropriate contrast ratios
  4. Performance: Styles are computed once per render, not per tooltip instance
  5. Maintainability: Single source of truth for tooltip styling

Future Enhancements

Potential improvements for the tooltip system:
  • Tooltip Animations: Add fade-in/fade-out transitions
  • Tooltip Positioning: Smart positioning to avoid screen edges
  • Tooltip Delays: Configurable hover delay before showing tooltip
  • Tooltip Themes: Additional theme variants for different contexts
  • Tooltip Icons: Built-in support for icons in tooltips

  • packages/client/src/ui/core/tooltip/tooltipStyles.ts - Core tooltip style utilities
  • packages/client/src/ui/core/tooltip/CursorTooltip.tsx - Tooltip component
  • packages/client/src/ui/core/tooltip/useTooltipPosition.ts - Tooltip positioning hook
  • packages/client/src/ui/stores/themeStore.ts - Theme management

Testing

Tooltip styles are tested indirectly through panel component tests:
  • packages/client/tests/unit/InventoryPanel/InventoryPanel.test.tsx
  • packages/client/tests/unit/EquipmentPanel.test.tsx
  • packages/client/tests/unit/BankPanel/BankPanel.test.tsx
  • packages/client/tests/unit/PrayerPanel/PrayerPanel.test.tsx
Visual regression tests verify tooltip appearance across all panels in E2E tests.