Skip to content

CssBuilder Struct

Ed Charbeneau edited this page Jan 15, 2020 · 1 revision

Creates a CssBuilder used to define conditional CSS classes used in a component. Call Build() to return the completed CSS Classes as a string. CssBuilder has a traditional constructor and two functional (static) convenience methods.

public struct CssBuilder

Constructors

Creates a CssBuilder used to define conditional CSS classes used in a component. Call Build() to return the completed CSS Classes as a string.

new CssBuilder(string)

Initializes a new instance of the CssBuilder struct.

public CssBuilder(string value)

Examples

string CssClass =>
       new CssBuilder("my-base")
         .AddClass("condition-1", when: true)
       .Build();
// CssClass: "my-base condition-1"

CssBuilder.Default(string)

Initializes a new instance of the CssBuilder struct with a default initial value.

public static CssBuilder Default(string value)

Examples

string CssClass =>
         CssBuilder.Default("my-base")
         .AddClass("condition-1", when: true)
       .Build();
// CssClass: "my-base condition-1"

CssBuilder.Empty()

Initializes a new instance of the CssBuilder struct with a string.Empty value.

public static CssBuilder Empty()

Examples

string CssClass =>
         CssBuilder.Empty()
         .AddClass("condition-1", when: true)
       .Build();
// CssClass: "condition-1"