HtmlForgeX

API Reference

Class

EmailBox

Namespace HtmlForgeX.Email
Assembly HtmlForgeX.Email
Implements
ILayoutAware ISpacingContainer IVisualElement<EmailBox> IRoundable<EmailBox> IRoundable

Represents a content box container for email layouts. Provides email-compatible styling with background colors, borders, and shadows.

Inheritance

Constructors

EmailBox 2 overloads
public EmailBox() #

Initializes a new instance of the EmailBox class.

public EmailBox(String backgroundColor, String padding = "48px") #

Initializes a new instance of the EmailBox class with custom styling.

Parameters

backgroundColor System.String requiredposition: 0
The background color.
padding System.String = "48px" optionalposition: 1
The padding inside the box.

Methods

Add(System.Action{HtmlForgeX.Email.BasicElement} config) #

Adds content to the box using a configuration action.

Parameters

config System.Action{HtmlForgeX.Email.BasicElement} required
The configuration action for the content.

Returns

The EmailBox object, allowing for method chaining.

public EmailBox CenterWithMargin(String verticalMargin = "24px") #
Returns: EmailBox

Centers the box with specific horizontal margins.

Parameters

verticalMargin System.String = "24px" optionalposition: 0
The vertical margin (top and bottom).

Returns

The EmailBox object, allowing for method chaining.

public EmailBox DisableBoxShadow() #
Returns: EmailBox

Disables the box shadow.

Returns

The EmailBox object, allowing for method chaining.

public override Void EvaluateLayout(LayoutContext context) #
Returns: Void

Calculates default border radius based on rounding mode and configuration.

Parameters

context HtmlForgeX.Email.LayoutContext requiredposition: 0
Layout evaluation context.
public String GetThemeBackgroundColor() #
Returns: String

Gets the appropriate background color based on theme mode.

public String GetThemeBorderColor() #
Returns: String

Gets the appropriate border color based on theme mode.

RenderHtml(System.Text.StringBuilder sb) #

Renders the EmailBox and its children. When nested inside another EmailBox, a wrapper table is only rendered when explicitly requested via UseWrapper.

Parameters

sb System.Text.StringBuilder required
The StringBuilder to append HTML to.
public override String ToString() #
Returns: String
WithBackground 2 overloads
public virtual EmailBox WithBackground(RGBColor color) #
Returns: EmailBox

Sets the background color of the box.

Parameters

color System.String requiredposition: 0
The background color.

Returns

The EmailBox object, allowing for method chaining.

WithBackground(HtmlForgeX.Email.RGBColor color) #

Sets the background color of the box.

Parameters

color HtmlForgeX.Email.RGBColor required
The background color.

Returns

The EmailBox object, allowing for method chaining.

WithBackgroundColor 2 overloads
public EmailBox WithBackgroundColor(RGBColor color) #
Returns: EmailBox

Sets the background color of the box.

Parameters

color System.String requiredposition: 0
The background color.

Returns

This instance for method chaining.

WithBackgroundColor(HtmlForgeX.Email.RGBColor color) #

Sets the background color of the box using RGBColor.

Parameters

color HtmlForgeX.Email.RGBColor required
The background color.

Returns

This instance for method chaining.

WithBorder 2 overloads
public virtual EmailBox WithBorder(BorderWidth width = Thin, String customValue = null) #
Returns: EmailBox

Sets the border width using a predefined size.

Parameters

width HtmlForgeX.Email.BorderWidth = Thin optionalposition: 0
The border width size.
customValue System.String = null optionalposition: 1
Custom value when using BorderWidth.Custom.

Returns

This instance for method chaining.

public virtual EmailBox WithBorder(Boolean enabled) #
Returns: EmailBox

Enables or disables borders for the box.

Parameters

enabled System.Boolean requiredposition: 0

Returns

This instance for method chaining.

WithBorderColor 2 overloads
public virtual EmailBox WithBorderColor(RGBColor color) #
Returns: EmailBox

Sets the border color of the box.

Parameters

color System.String requiredposition: 0
The border color.

Returns

The EmailBox object, allowing for method chaining.

WithBorderColor(HtmlForgeX.Email.RGBColor color) #

Sets the border color of the box using RGBColor.

Parameters

color HtmlForgeX.Email.RGBColor required
The border color.

Returns

The EmailBox object, allowing for method chaining.

public virtual EmailBox WithBorderRadius(String radius) #
Returns: EmailBox

Sets the border radius of the box.

Parameters

radius System.String requiredposition: 0
The border radius value.

Returns

The EmailBox object, allowing for method chaining.

public EmailBox WithBorderStyle(BorderWidth width = Thin, String color = null, Radius radius = Medium) #
Returns: EmailBox

Sets the border style with width, color, and radius.

Parameters

width HtmlForgeX.Email.BorderWidth = Thin optionalposition: 0
The border width.
color System.String = null optionalposition: 1
The border color.
radius HtmlForgeX.Email.Radius = Medium optionalposition: 2
The border radius.

Returns

This instance for method chaining.

public EmailBox WithMaxWidth(String maxWidth) #
Returns: EmailBox

Sets the maximum width of the box.

Parameters

maxWidth System.String requiredposition: 0
The maximum width value.

Returns

The EmailBox object, allowing for method chaining.

WithRounded 2 overloads
public virtual EmailBox WithRounded(Radius radius = Medium, String customValue = null) #
Returns: EmailBox

Sets the border radius using a predefined size.

Parameters

radius HtmlForgeX.Email.Radius = Medium optionalposition: 0
The border radius size.
customValue System.String = null optionalposition: 1
Custom value when using Custom.

Returns

This instance for method chaining.

public virtual EmailBox WithRounded() #
Returns: EmailBox

Applies the default border radius (6px) for rounded corners.

Returns

This instance for method chaining.

public virtual EmailBox WithRoundingMode(RoundingMode mode) #
Returns: EmailBox

Sets the rounding mode for this box.

Parameters

mode HtmlForgeX.Email.RoundingMode requiredposition: 0
Rounding mode.

Returns

The box instance.

public EmailBox WithShadow(Boolean enabled = true) #
Returns: EmailBox

Enables or disables the box shadow.

Parameters

enabled System.Boolean = true optionalposition: 0
Whether to include box shadow.

Returns

This instance for method chaining.

WithSpacing 2 overloads
public EmailBox WithSpacing(EmailSpacing spacing) #
Returns: EmailBox

Sets the spacing around the box using semantic sizing.

Parameters

spacing HtmlForgeX.Email.EmailSpacing requiredposition: 0
The spacing size to apply.

Returns

This instance for method chaining.

public EmailBox WithSpacing(EmailSpacing above, EmailSpacing below) #
Returns: EmailBox

Sets different spacing above and below the box.

Parameters

above HtmlForgeX.Email.EmailSpacing requiredposition: 0
The spacing size above.
below HtmlForgeX.Email.EmailSpacing requiredposition: 1
The spacing size below.

Returns

This instance for method chaining.

public EmailBox WithStructuralMode(Boolean enabled) #
Returns: EmailBox

Enables or disables structural mode. When enabled, the box renders as a simple table without visual styling. When disabled, full visual styling is applied.

Parameters

enabled System.Boolean requiredposition: 0
Whether structural mode should be enabled.

Returns

The EmailBox object, allowing for method chaining.

public EmailBox WithWrapper(Boolean enabled = true) #
Returns: EmailBox

Forces this box to render its own table wrapper even when nested inside another EmailBox.

Parameters

enabled System.Boolean = true optionalposition: 0
Whether the wrapper should be rendered.

Returns

The EmailBox object, allowing for method chaining.

Properties

public virtual String BackgroundColor { get; set; } #

Gets or sets the background color of the box.

public virtual String BorderRadius { get; set; } #

Gets or sets the border radius of the box.

public virtual RoundingMode RoundingMode { get; set; } #

Gets or sets how border radius should be applied.

public virtual String BorderColor { get; set; } #

Gets or sets the border color of the box.

public virtual String BorderWidth { get; set; } #

Gets or sets the border width of the box.

public Boolean IncludeBoxShadow { get; set; } #

Gets or sets whether to include box shadow.

public String BoxShadow { get; set; } #

Gets or sets the box shadow CSS.

public String InlineStyle { get; set; } #

Gets or sets additional inline styles.

public Boolean UseConsistentSpacing { get; set; } #

Gets or sets whether to use consistent spacing between elements. When true, applies consistent vertical spacing between child elements.

public String ChildSpacing { get; set; } #

Gets or sets the spacing between child elements.

public String OuterMargin { get; set; } #

Gets or sets the outer margin around the entire box.

public String MaxWidth { get; set; } #

Gets or sets the maximum width of the box. If not explicitly set, uses the email's configured layout width.

public Boolean StructuralMode { get; set; } #

Gets or sets whether to use structural mode (no visual styling). When true, renders as a simple table structure without borders, shadows, or background. Perfect for headers, footers, or when you just need layout structure.

public Boolean UseWrapper { get; set; } #

Gets or sets whether this box should render its own table wrapper when nested inside another EmailBox.

public override String Padding { get; set; } #

Extension Methods

public static EmailBox WithMargin(EmailBox box, EmailSpacing all) #
Returns: EmailBox

Sets a uniform margin on an EmailBox using a typed spacing value.

Parameters

box HtmlForgeX.Email.EmailBox requiredposition: 0
Target container.
all HtmlForgeX.Email.EmailSpacing requiredposition: 1
Spacing applied to all sides.
WithPadding 3 overloads
public static EmailBox WithPadding(EmailBox box, EmailSpacing all) #
Returns: EmailBox

Sets uniform padding on an EmailBox using a typed spacing value.

Parameters

box HtmlForgeX.Email.EmailBox requiredposition: 0
Target container.
all HtmlForgeX.Email.EmailSpacing requiredposition: 1
Spacing applied to all sides.
public static EmailBox WithPadding(EmailBox box, EmailSpacing vertical, EmailSpacing horizontal) #
Returns: EmailBox

Sets vertical and horizontal padding on an EmailBox using typed spacing values.

Parameters

box HtmlForgeX.Email.EmailBox requiredposition: 0
Target container.
vertical HtmlForgeX.Email.EmailSpacing requiredposition: 1
Top and bottom padding.
horizontal HtmlForgeX.Email.EmailSpacing requiredposition: 2
Left and right padding.
public static EmailBox WithPadding(EmailBox box, EmailSpacing top, EmailSpacing right, EmailSpacing bottom, EmailSpacing left) #
Returns: EmailBox

Sets top/right/bottom/left padding on an EmailBox using typed spacing values.

Parameters

box HtmlForgeX.Email.EmailBox requiredposition: 0
Target container.
top HtmlForgeX.Email.EmailSpacing requiredposition: 1
Top padding.
right HtmlForgeX.Email.EmailSpacing requiredposition: 2
Right padding.
bottom HtmlForgeX.Email.EmailSpacing requiredposition: 3
Bottom padding.
left HtmlForgeX.Email.EmailSpacing requiredposition: 4
Left padding.