Button AddOn
Overview
The Button AddOn type allows you to insert pre-styled call-to-action buttons into the Beefree editor. This is perfect for providing users with brand-compliant button styles, reducing design work and ensuring consistency across emails.
Prerequisites
Before implementing a Button AddOn in your code, you must first create the addon in the Beefree SDK Developer Console:
Log into the Developer Console and navigate to your application
Create a new Custom AddOn and select "Button" as the type
Configure the addon with a unique handle (e.g.,
my-button-addon)Choose your implementation method (Content Dialog or External iframe)
Save the addon configuration
Setup in Beefree SDK Console
Name
Simple Button AddOn
Type
Button ← Select from dropdown
Handle
simple-button-addon
Method
Content Dialog or External iframe
Content Object Schema
Required Structure
The Button AddOn requires a specific data structure to properly insert button content into the editor. The schema defines how the button will appear and behave when added to the email template.
Important: Padding and border-radius values must be numbers (representing pixels), not strings. For example, use 'border-radius': 4 not 'border-radius': '4px'.
Basic Example
This minimal example demonstrates the simplest button you can create, containing only the required type and label properties. This button will use the editor's default styling and can be customized by the user after insertion.
Styled Example
This example shows a fully customized button with branded colors, sizing, and padding. By pre-configuring these properties, you ensure consistent brand styling across all buttons without requiring users to manually style each one.
Content Dialog Implementation
Basic Handler
The Content Dialog method allows you to programmatically insert button content using a JavaScript handler function. When users drag and drop your button addon onto the stage, the handler is immediately invoked with resolve and reject functions that control the insertion flow. This basic pattern immediately resolves with a pre-defined button, making it perfect for simple use cases where no user interaction is needed.
Pattern: Button Style Library
This advanced pattern demonstrates how to create a library of pre-defined button styles for users to choose from. By opening a custom UI selector, users can pick between different button variants (primary, secondary, etc.) while maintaining brand consistency. The handler waits for user selection before resolving, giving you full control over the insertion flow.
Iframe Implementation
Conceptual Flow
The Iframe method allows you to build a completely custom UI for your button addon using any web technology. Your iframe application is loaded inside the Beefree editor and communicates using postMessage events. This approach gives you complete control over the user experience, letting you create rich interfaces for button customization, validation, and preview before insertion.
Required postMessage Communication
When using the Iframe method, your application must follow a specific message protocol to communicate with the Beefree editor. First, send a "loaded" message to indicate your iframe is ready. Then, listen for the "init" message from Beefree which provides context about the editor state. Finally, send "onSave" with your button data when ready to insert, or "onCancel" if the user abandons the action.
1. Send "loaded" when your iframe is ready:
2. Listen for "init" and "load" messages from Beefree:
3. Send "onSave" with button data:
4. Send "onCancel" if user cancels:
Simple Iframe Example
This complete HTML example shows a simple but functional button configuration interface. It demonstrates the full communication protocol with Beefree, including the loaded notification, button configuration inputs, and save/cancel actions. You can use this as a starting point and enhance it with your own styling, validation, and additional configuration options.
Last updated
Was this helpful?

