Label<TValue> Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Renders a <label> element for a specified field, reading the display name from
DisplayAttribute or
DisplayNameAttribute if present, or falling back to the property name.
public class Label<TValue> : Microsoft.AspNetCore.Components.IComponent
type Label<'Value> = class
interface IComponent
Public Class Label(Of TValue)
Implements IComponent
Type Parameters
- TValue
The type of the field.
- Inheritance
-
Label<TValue>
- Implements
Remarks
The component supports two usage patterns:
Nested (wrapping) pattern: When ChildContent is provided, the label wraps the input component, providing implicit HTML association without requiring matching for/id attributes.
Non-nested pattern: When ChildContent is not provided, the label renders with a for attribute matching the field expression. The corresponding input component must have a matching id attribute (which is automatically generated by input components derived from InputBase<TValue>).
Constructors
| Name | Description |
|---|---|
| Label<TValue>() | |
Properties
| Name | Description |
|---|---|
| AdditionalAttributes |
Gets or sets a collection of additional attributes that will be applied to the label element. |
| ChildContent |
Gets or sets the child content to be rendered inside the label element. Typically this contains an input component that will be implicitly associated with the label. |
| For |
Specifies the field for which the label should be rendered. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IComponent.Attach(RenderHandle) |
Attaches the component to a RenderHandle. |
| IComponent.SetParametersAsync(ParameterView) |
Sets parameters supplied by the component's parent in the render tree. |