Custom Menu Slots
TypeScript Tip: Type Inference with commandListBuilder
contextMenu: {
commandListBuilder: (builtInItems) => {
return [
...builtInItems,
{
command: 'custom-action',
title: 'My Action',
slotRenderer: (cmdItem, args) => `<div>${cmdItem.title}</div>`,
}
] as Array<MenuCommandItem | GridMenuItem | 'divider'>;
}
}return [...] as Array<MenuCommandItem | 'divider'>;Core Concept
Slot Renderer Callback
Basic Example - HTML String Rendering
Advanced Example - HTMLElement Objects
Default Menu-Level Renderer
Menu Types & Configuration
Header Menu
Cell Menu
Context Menu
Grid Menu
Framework Integration Examples
Vanilla JavaScript
Angular - Dynamic Components
React - Using Hooks
Vue - Using createApp
Real-World Use Cases
1. Add Keyboard Shortcuts
2. Add Status Indicators
3. Add Dynamic Content Based on Context
4. Add Interactive Elements
5. Add Badges and Status Labels
6. Gradient and Styled Icons
Notes and Best Practices
Styling Custom Menu Items
Migration from Static Rendering
Error Handling
Last updated