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 objectaccentColor?: string- Optional accent color (defaults totheme.colors.accent.secondary)
React.CSSProperties
Example:
getTooltipMetaStyle(theme)
Returns styling for metadata/secondary text (e.g., item type, level requirements).
Parameters:
theme: Theme- Current theme object
React.CSSProperties
Example:
getTooltipBodyStyle(theme)
Returns styling for body content text (e.g., descriptions, stats).
Parameters:
theme: Theme- Current theme object
React.CSSProperties
Example:
getTooltipDividerStyle(theme, accentColor?)
Returns styling for section dividers within tooltips.
Parameters:
theme: Theme- Current theme objectaccentColor?: string- Optional accent color for border (defaults totheme.colors.border.default)
React.CSSProperties
Example:
getTooltipTagStyle(theme)
Returns styling for tag/badge elements (e.g., item categories, skill types).
Parameters:
theme: Theme- Current theme object
React.CSSProperties
Example:
getTooltipStatusStyle(theme, tone)
Returns styling for status indicators (success/danger/warning/default).
Parameters:
theme: Theme- Current theme objecttone: 'default' | 'success' | 'danger' | 'warning'- Status tone
React.CSSProperties
Example:
success: Green background/border/textdanger: Red background/border/textwarning: Yellow/orange background/border/textdefault: 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:- InventoryPanel - Item tooltips with bonuses and descriptions
- EquipmentPanel - Equipment slot tooltips with stats and requirements
- BankPanel - Bank item tooltips with tab info and value
- SpellsPanel - Spell tooltips with rune costs and effects
- PrayerPanel - Prayer tooltips with drain rates and requirements
- SkillsPanel - Skill tooltips with XP progress and level info
- TradePanel - Trade item tooltips with quantities
- StorePanel - Store item tooltips with prices and stock
- LootWindowPanel - Loot item tooltips with item types
- ActionBarPanel - Action bar slot tooltips with shortcuts
- DuelPanel - Duel stake tooltips with item info
Migration Guide
Before (Duplicated Styles)
After (Centralized Utilities)
Design Principles
- Consistency: All tooltips use the same visual hierarchy
- Theming: Styles adapt to current theme (Hyperscape, Dark, Light)
- Accessibility: Clear text hierarchy with appropriate contrast ratios
- Performance: Styles are computed once per render, not per tooltip instance
- 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
Related Files
packages/client/src/ui/core/tooltip/tooltipStyles.ts- Core tooltip style utilitiespackages/client/src/ui/core/tooltip/CursorTooltip.tsx- Tooltip componentpackages/client/src/ui/core/tooltip/useTooltipPosition.ts- Tooltip positioning hookpackages/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.tsxpackages/client/tests/unit/EquipmentPanel.test.tsxpackages/client/tests/unit/BankPanel/BankPanel.test.tsxpackages/client/tests/unit/PrayerPanel/PrayerPanel.test.tsx