Tag Helper Output Structure

All RazorForms tag helpers use two main template files to create their output. Validity-aware tag helpers use ~/RazorFormsTemplates/Partials/ValidityAwareContent.cshtml, while validity-unaware tag helpers use ~/RazorFormsTemplates/Partials/Content.cshtml.

Parts of the markup can be modified or disabled via configuration. For more information on configuring RazorForms, see configuration. If you want to make changes to the markup that aren't supported by configuration, you can create custom templates.

Validity-unaware tag helper output

<div> <!-- component wrapper -->
<div> <!-- label wrapper, disable in configuration -->
<label>...</label>
</div>
<div> <!-- input wrapper, disable in configuration -->
<input/>
</div>
</div>

Component wrapper

The entire component is wrapped with a <div>. This cannot be disabled in configuration. The component wrapper classes can be set with FormComponentOptions.ComponentWrapperClasses.

Label wrapper

The <label> is wrapped with its own <div>. This can be disabled in configuration. The label wrapper classes can be set with FormComponentOptions.LabelWrapperClasses.

Label

The <label> classes can be set with FormComponentOptions.LabelClasses.

Input wrapper

The <input> is wrapped with its own <div>. This can be disabled in configuration. The input wrapper classes can be set with FormComponentOptions.InputWrapperClasses.

Input

The <input> classes can be set with FormComponentOptions.InputClasses.

Additional configuration options

Validity-aware tag helper output

<div> <!-- component wrapper -->
<div> <!-- input block wrapper -->
<div> <!-- label wrapper, disable in configuration -->
<label>...</label>
</div>

<div> <!-- input wrapper, disable in configuration -->
<!-- type varies based on model -->
<input/>
</div>
</div>

<ul> <!-- error wrapper, only rendered if errors are present -->
<li>...</li> <!-- error -->
</ul>
</div>

Component wrapper

The entire component is wrapped with a <div>. This cannot be disabled in configuration. The component wrapper supports the following configuration options:

Input block wrapper

The <input> and <label> are wrapped with a <div>. This cannot be disabled in configuration. The input block wrapper supports the following configuration options:

Label wrapper

The <label> is wrapped with its own <div>. This can be disabled in configuration. The label wrapper supports the following configuration options:

Label

The <label> supports the following configuration options:

Input wrapper

The <input> is wrapped with its own <div>. This can be disabled in configuration. The input wrapper supports the following configuration options:

Input

The <input> supports the following configuration options:

Error wrapper

The <ul> wraps around error messages. This cannot be disabled in configuration. Because the error wrapper is intended only to convey error information, it doesn't support validity-based classes. The error wrapper supports the following configuration options:

Error

The <li> contains error messages. This cannot be disabled in configuration. Because the error is intended only to convey error information, it doesn't support validity-based classes. The error supports the following configuration options:

Additional configuration options