Radial Menu Spell
TheRadialMenuSpell component creates a beautiful circular menu that appears at the cursor position, perfect for providing quick contextual actions. It features smooth animations, visual feedback, and supports both keyboard and mouse activation.
Features
- Circular Layout: Items arranged in a circle for equal access
- Visual Feedback: Animated hover states and selection indicators
- Cancel Zone: Center area for canceling without action
- Flexible Activation: Supports keyboard shortcuts and mouse events
- Hold-to-Select: Natural interaction pattern for quick actions
- Escape Support: Press ESC to cancel without executing
- Theme Integration: Adapts to Cedar’s light/dark mode
- Icon Support: Use emojis or Lucide icons for menu items
Installation
Basic Usage
Props
RadialMenuSpell Props
RadialMenuItem Interface
Activation Patterns
Hold Pattern (Recommended)
The most natural interaction for radial menus is the hold pattern:- Right-click and hold to open menu
- Move mouse to desired item (it highlights)
- Release to execute action
- Or move to center and release to cancel
Toggle Pattern
For persistent menus that stay open:- Press Space to open menu
- Move mouse to select item
- Click to execute or press Space again to close
Keyboard Shortcut
Bind to any keyboard shortcut:Advanced Examples
AI Actions Menu
Create an AI-powered context menu:Emoji-Based Menu
Use emojis for a playful interface:Dynamic Menu Items
Generate menu items based on context:Visual Customization
The radial menu automatically adapts to Cedar’s styling system:Theme Integration
The component uses Cedar’s styling context:- Brand Color: Used for hover states and selection
- Dark Mode: Automatically adjusts colors and contrasts
- Text Colors: Adapts based on theme
Layout Constants
The component uses these layout constants (defined in the component):Interaction Details
Mouse Behavior
- Hover: Moving mouse over items highlights them
- Center Zone: Moving to center shows “Cancel”
- Selection: Release (hold mode) or click (toggle mode) to select
- Visual Feedback: Animated ring shows current selection
Keyboard Support
- ESC: Cancel without executing any action
- Activation Keys: Defined by
activationConditions
Position Handling
- Mouse Events: Menu appears at cursor position
- Keyboard Events: Menu appears at viewport center
- Smart Positioning: Stays within viewport bounds
Best Practices
1. Limit Item Count
Keep menus focused with 3-8 items:2. Use Clear Icons
Choose recognizable icons:3. Consistent Actions
KeeponInvoke callbacks focused:
4. Handle Errors Gracefully
Accessibility Considerations
While the radial menu is primarily a visual component, consider these accessibility aspects:- Alternative Activation: Provide keyboard shortcuts as alternatives
- Clear Labels: Use descriptive titles for screen readers
- Escape Route: Always allow ESC key to cancel
- Visual Contrast: The component respects Cedar’s theme for proper contrast
Performance Notes
- Singleton Management: Uses Cedar’s spell system for efficient event handling
- Animation Performance: Uses CSS transforms for smooth animations
- Memory Efficient: Automatically cleaned up when component unmounts
- Event Delegation: Single set of listeners for all instances
Common Patterns
Tool Selection Menu
Navigation Menu
Media Controls
Troubleshooting
Menu doesn’t appear
- Check that the spell ID is unique
- Verify activation conditions are correct
- Ensure component is mounted
Items not executing
- Verify
onInvokecallbacks are defined - Check for errors in callback functions
- Ensure Cedar store is accessible
Visual issues
- Component adapts to Cedar’s theme automatically
- Check that Cedar styling context is provided
- Verify Container3D component is available
Related Components
- TooltipMenuSpell - Linear menu for text selections
- QuestioningSpell - Interactive cursor for exploration
- Creating Custom Spells - Build your own spell components

