Table of Contents

Struct CssBuilder

Namespace
MudBlazor.Utilities
Assembly
MudBlazor.dll

Represents a builder for creating CSS classes used in a component.

public struct CssBuilder
Inherited Members
Extension Methods

Constructors

CssBuilder()

Creates an empty instance of CssBuilder.

public CssBuilder()

Remarks

Call Build() to return the completed CSS classes as a string.

CssBuilder(string?)

Initializes a new instance of the CssBuilder class with the specified initial value.

public CssBuilder(string? value)

Parameters

value string

The initial CSS class value.

Remarks

Call Build() to return the completed CSS classes as a string.

Methods

AddClass(CssBuilder, bool)

Adds a conditional nested CssBuilder to the builder with a space separator.

public CssBuilder AddClass(CssBuilder builder, bool when = true)

Parameters

builder CssBuilder

The CssBuilder to conditionally add.

when bool

The condition in which the CssBuilder is added.

Returns

CssBuilder

The CssBuilder instance.

AddClass(CssBuilder, Func<bool>?)

Adds a conditional CSS class to the builder with a space separator.

public CssBuilder AddClass(CssBuilder builder, Func<bool>? when = null)

Parameters

builder CssBuilder

The CssBuilder to conditionally add.

when Func<bool>

The condition in which the CSS class is added.

Returns

CssBuilder

The CssBuilder instance.

AddClass(Func<string?>, bool)

Adds a conditional CSS class to the builder with a space separator.

public CssBuilder AddClass(Func<string?> value, bool when = true)

Parameters

value Func<string>

The function that returns a CSS class to conditionally add.

when bool

The condition in which the CSS class is added.

Returns

CssBuilder

The CssBuilder instance.

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

Adds a conditional CSS class to the builder with a space separator.

public CssBuilder AddClass(Func<string?> value, Func<bool>? when = null)

Parameters

value Func<string>

The function that returns a CSS class to conditionally add.

when Func<bool>

The condition in which the CSS class is added.

Returns

CssBuilder

The CssBuilder instance.

AddClass(string?)

Adds a CSS class to the builder with a space separator.

public CssBuilder AddClass(string? value)

Parameters

value string

The CSS class to add.

Returns

CssBuilder

The CssBuilder instance.

AddClass(string?, bool)

Adds a conditional CSS class to the builder with a space separator.

public CssBuilder AddClass(string? value, bool when)

Parameters

value string

The CSS class to conditionally add.

when bool

The nullable condition in which the CSS class is added.

Returns

CssBuilder

The CssBuilder instance.

AddClass(string?, Func<bool>?)

Adds a conditional CSS class to the builder with a space separator.

public CssBuilder AddClass(string? value, Func<bool>? when)

Parameters

value string

The CSS class to conditionally add.

when Func<bool>

The condition in which the CSS class is added.

Returns

CssBuilder

The CssBuilder instance.

AddClass(string?, bool?)

Adds a conditional CSS class to the builder with space separator.

public CssBuilder AddClass(string? value, bool? when)

Parameters

value string

CSS class to conditionally add.

when bool?

Nullable condition in which the CSS class is added.

Returns

CssBuilder

The CssBuilder instance.

AddClassFromAttributes(IReadOnlyDictionary<string, object>?)

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

public CssBuilder AddClassFromAttributes(IReadOnlyDictionary<string, object>? additionalAttributes)

Parameters

additionalAttributes IReadOnlyDictionary<string, object>

Additional attribute splat parameters.

Returns

CssBuilder

The CssBuilder instance.

AddValue(string?)

Adds a raw string to the builder that will be concatenated with the next class or value added to the builder.

public CssBuilder AddValue(string? value)

Parameters

value string

The string value to add.

Returns

CssBuilder

The CssBuilder instance.

Build()

Finalizes the completed CSS classes as a string.

public string Build()

Returns

string

The string representation of the CSS classes.

Default(string)

Creates a new instance of CssBuilder with the specified initial value.

public static CssBuilder Default(string value)

Parameters

value string

The initial CSS class value.

Returns

CssBuilder

The CssBuilder instance.

Remarks

Call Build() to return the completed CSS classes as a string.

Empty()

Creates an empty instance of CssBuilder.

public static CssBuilder Empty()

Returns

CssBuilder

The CssBuilder instance.

Remarks

Call Build() to return the completed CSS classes as a string.

ToString()

public override string ToString()

Returns

string