Choosing an editor

How fields pick their input, and how to pick another

Every field gets an editor from its type and attributes. Most of the time you don't need to choose one.

PropertyEditor
string, GuidText input. [EmailAddress], [Phone], [Url] or [DataType] pick email, tel, url or password.
NumbersNumber input
[DataType(DataType.MultilineText)]Textarea
[DataType(DataType.Html)]Rich text editor
DateOnly, DateTime, TimeOnlyDate, date and time, or time input
boolCheckbox
bool?Select with Yes, No and Not set
EnumSelect of its members
List<string>, int[] and other lists of text or numbersList editor
Dictionary<string, string> and other simple dictionariesDictionary editor
Foreign key to a resource (EF Core)Lookup
Many-to-many navigation to a resource (EF Core)Multi-lookup

One gotcha: a string without [DataType] is a single-line input, however long it gets. Give descriptions, bios and notes a textarea.

Picking another editor

Each editor has its own method on the field. Pass a callback to change its settings:

fields.Add(trip => trip.Summary).UseTextareaEditor(textarea => textarea.Rows = 4);
fields.Add(trip => trip.IsPublished).UseToggleEditor();
fields.Add(trip => trip.Difficulty).UseSegmentedControlEditor();
fields.Add(trip => trip.MaxGroupSize).UseSliderEditor(slider =>
{
    slider.Min = 2;
    slider.Max = 16;
    slider.ValueFormat = "{0} people";
});

Settings you don't set come from the property where possible. A slider takes its range from [Range], for example.

The editors

EditorMethodPage
Text inputUseTextInputEditorInputs
TextareaUseTextareaEditorInputs
Date, date and time, timeUseDateInputEditor, UseDateTimeInputEditor, UseTimeInputEditorInputs
Checkbox, switchUseCheckboxEditor, UseToggleEditorInputs
SliderUseSliderEditorInputs
One-time codeUseOneTimeCodeEditorInputs
Select, radio group, segmented controlUseSelectEditor, UseRadioGroupEditor, UseSegmentedControlEditorChoices
Checkbox group, toggle groupUseCheckboxGroupEditor, UseToggleGroupEditorChoices
List, dictionaryUseListEditor, UseDictionaryEditorLists and dictionaries
Lookup, multi-lookupUseLookupSheetEditor, UseMultiLookupSheetEditorForeign keys, many-to-many
ImageUseImageEditorImages
Rich textUseRichTextEditorRich text
IconUseIconEditorIcons

Need something else, like a colour picker? Write a custom editor. There's no general file upload editor yet.

Extra CSS classes

Every editor has ClassNames, for adding classes from your own stylesheet to its parts, such as Control, Label and Description:

fields.Add(trip => trip.Summary).UseTextareaEditor(textarea => textarea.ClassNames.Control = "trip-summary");

The panel's stylesheet only has the classes its own components use, so Tailwind utilities won't work here unless you add a stylesheet that has them.

On this page