Table of Contents

Struct StyleBuilder

Namespace
MudBlazor.Utilities
Assembly
MudBlazor.dll

Represents a builder for creating in-line styles used in a component.

public struct StyleBuilder
Inherited Members
Extension Methods

Constructors

StyleBuilder()

Creates an empty instance of StyleBuilder.

public StyleBuilder()

Remarks

Call Build()> to return the completed style as a string.

StyleBuilder(string, string)

Initializes a new instance of the StyleBuilder class with the specified property and value.

public StyleBuilder(string prop, string value)

Parameters

prop string

The CSS property.

value string

The value of the property.

Remarks

Call Build()> to return the completed style as a string.

Methods

AddStyle(StyleBuilder)

Adds a conditional nested StyleBuilder to the builder with a separator and closing semicolon.

public StyleBuilder AddStyle(StyleBuilder builder)

Parameters

builder StyleBuilder

The StyleBuilder to conditionally add.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(StyleBuilder, bool)

Adds a conditional nested StyleBuilder to the builder with a separator and closing semicolon.

public StyleBuilder AddStyle(StyleBuilder builder, bool when)

Parameters

builder StyleBuilder

The StyleBuilder to conditionally add.

when bool

The condition in which the style is added.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(StyleBuilder, Func<bool>?)

Adds a conditional in-line style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(StyleBuilder builder, Func<bool>? when)

Parameters

builder StyleBuilder

The StyleBuilder to conditionally add.

when Func<bool>

The condition in which the styles are added.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string?)

Adds a conditional in-line style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string? style)

Parameters

style string

The style to add.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string, Action<ValueBuilder>, bool)

Adds a conditional in-line style to the builder with a space separator and closing semicolon. A ValueBuilder action defines a complex set of values for the property.

public StyleBuilder AddStyle(string prop, Action<ValueBuilder> builder, bool when = true)

Parameters

prop string

The CSS property.

builder Action<ValueBuilder>

The ValueBuilder action that defines the values for the property.

when bool

The condition in which the style is added.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string?, bool)

Adds a conditional style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string? style, bool when)

Parameters

style string

The style to add.

when bool

The condition.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string?, Func<bool>?)

Adds a conditional style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string? style, Func<bool>? when)

Parameters

style string

The style to add.

when Func<bool>

The condition as function.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string, Func<string?>, bool)

Adds a conditional in-line style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string prop, Func<string?> value, bool when = true)

Parameters

prop string

The CSS property.

value Func<string>

The value of the property to conditionally add.

when bool

The condition in which the style is added.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string, Func<string?>, Func<bool>?)

Adds a conditional in-line style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string prop, Func<string?> value, Func<bool>? when = null)

Parameters

prop string

The CSS property.

value Func<string>

The value of the property to conditionally add.

when Func<bool>

The condition in which the style is added.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string, string?)

Adds a conditional in-line style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string prop, string? value)

Parameters

prop string

The CSS property.

value string

The value of the property.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string, string?, bool)

Adds a conditional in-line style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string prop, string? value, bool when)

Parameters

prop string

The CSS property.

value string

The value of the property to conditionally add.

when bool

The condition in which the style is added.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyle(string, string?, Func<bool>?)

Adds a conditional in-line style to the builder with a space separator and closing semicolon.

public StyleBuilder AddStyle(string prop, string? value, Func<bool>? when)

Parameters

prop string

The CSS property.

value string

The value of the property to conditionally add.

when Func<bool>

The condition in which the style is added.

Returns

StyleBuilder

The StyleBuilder instance.

AddStyleFromAttributes(IReadOnlyDictionary<string, object>?)

Adds a conditional in-line style when it exists in a dictionary to the builder with a separator. This is a null-safe operation.

public StyleBuilder AddStyleFromAttributes(IReadOnlyDictionary<string, object>? additionalAttributes)

Parameters

additionalAttributes IReadOnlyDictionary<string, object>

Additional attribute splat parameters.

Returns

StyleBuilder

The StyleBuilder instance.

Build()

Finalizes the completed style as a string.

public string Build()

Returns

string

The string representation of the style.

Default(string?)

Creates a new instance of StyleBuilder with the specified style.

public static StyleBuilder Default(string? style)

Parameters

style string

The CSS style.

Returns

StyleBuilder

The StyleBuilder instance.

Remarks

Call Build()> to return the completed style as a string.

Default(string, string)

Creates a new instance of StyleBuilder with the specified property and value.

public static StyleBuilder Default(string prop, string value)

Parameters

prop string

The CSS property.

value string

The value of the property.

Returns

StyleBuilder

The StyleBuilder instance.

Remarks

Call Build()> to return the completed style as a string.

Empty()

Creates an empty instance of StyleBuilder.

public static StyleBuilder Empty()

Returns

StyleBuilder

The StyleBuilder instance.

Remarks

Call Build()> to return the completed style as a string.

ToString()

public override string ToString()

Returns

string