Struct StyleBuilder
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
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
builderStyleBuilderThe 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
builderStyleBuilderThe StyleBuilder to conditionally add.
whenboolThe 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
builderStyleBuilderThe StyleBuilder to conditionally add.
whenFunc<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
stylestringThe 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
propstringThe CSS property.
builderAction<ValueBuilder>The ValueBuilder action that defines the values for the property.
whenboolThe 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
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
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
propstringThe CSS property.
valueFunc<string>The value of the property to conditionally add.
whenboolThe 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
propstringThe CSS property.
valueFunc<string>The value of the property to conditionally add.
whenFunc<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
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
propstringThe CSS property.
valuestringThe value of the property to conditionally add.
whenboolThe 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
propstringThe CSS property.
valuestringThe value of the property to conditionally add.
whenFunc<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
additionalAttributesIReadOnlyDictionary<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
stylestringThe 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
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()