ColorFieldBuilderFor configures TextFieldBuilder as a browser-native color selector with the same presentation and disabled-state behavior as other fields.

Presentation Styles And Alerts

Color

C#
@model DMBFormBuilderLabs.Models.FormBuilderColorInputExampleModel

@Html.ColorFieldBuilderFor(m => m.Color).Render()

Floating color

C#
@model DMBFormBuilderLabs.Models.FormBuilderColorInputExampleModel

@Html.ColorFieldBuilderFor(m => m.FloatingColor).SetLabelPresentation(FormLabelPresentation.Floating).Render()

Inline color

C#
@model DMBFormBuilderLabs.Models.FormBuilderColorInputExampleModel

@Html.ColorFieldBuilderFor(m => m.InlineColor).SetLabelPresentation(FormLabelPresentation.Inline).Render()

Grouped color

C#
@model DMBFormBuilderLabs.Models.FormBuilderColorInputExampleModel

@Html.ColorFieldBuilderFor(m => m.GroupColor).SetLabelPresentation(FormLabelPresentation.Group).SetGroupIcon("bi bi-palette").Render()

Hidden label

C#
@model DMBFormBuilderLabs.Models.FormBuilderColorInputExampleModel

@Html.ColorFieldBuilderFor(m => m.HiddenColor).SetLabelPresentation(FormLabelPresentation.Hidden).Render()

State Variants

Locked color

C#
@model DMBFormBuilderLabs.Models.FormBuilderColorInputExampleModel

@Html.ColorFieldBuilderFor(m => m.DisabledColor).SetDisabled().Render()
Required field

Code Examples

ColorInputFields.cshtml
@Html.ColorFieldBuilderFor(m => m.Color).Render()
@Html.ColorFieldBuilderFor(m => m.FloatingColor).SetLabelPresentation(FormLabelPresentation.Floating).Render()
@Html.ColorFieldBuilderFor(m => m.InlineColor).SetLabelPresentation(FormLabelPresentation.Inline).Render()
@Html.ColorFieldBuilderFor(m => m.GroupColor).SetLabelPresentation(FormLabelPresentation.Group).SetGroupIcon("bi bi-palette").Render()
@Html.ColorFieldBuilderFor(m => m.HiddenColor).SetLabelPresentation(FormLabelPresentation.Hidden).Render()
@Html.ColorFieldBuilderFor(m => m.DisabledColor).SetDisabled().Render()