RadzenLabel Class

A label component for associating descriptive text with form input components. RadzenLabel creates accessible labels linked to input fields via the HTML for/id relationship. Provides descriptive text for form inputs, improving usability and accessibility. When properly associated with an input (via the Component property), clicking the label focuses the input. Features association linking to input components via the Component property (matching the input's Name), proper label/input relationships for screen readers, click behavior that focuses the associated input, and content display via Text property or custom content via ChildContent. Always use labels with form inputs for better UX and accessibility compliance. The Component property should match the Name property of the input it describes.

Inheritance

Object

ComponentBase

RadzenComponent

RadzenLabel

Implements

IComponent

IHandleEvent

IHandleAfterRender

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenLabel : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender

Examples

Basic label with input:

<RadzenLabel Text="Email Address" Component="EmailInput" />
<RadzenTextBox Name="EmailInput" @bind-Value=@email />

Label with custom content:

<RadzenLabel Component="PasswordInput">
    Password <span style="color: red;">*</span>
</RadzenLabel>
<RadzenPassword Name="PasswordInput" @bind-Value=@password />

Constructors

RadzenLabellink

A label component for associating descriptive text with form input components. RadzenLabel creates accessible labels linked to input fields via the HTML for/id relationship. Provides descriptive text for form inputs, improving usability and accessibility. When properly associated with an input (via the Component property), clicking the label focuses the input. Features association linking to input components via the Component property (matching the input's Name), proper label/input relationships for screen readers, click behavior that focuses the associated input, and content display via Text property or custom content via ChildContent. Always use labels with form inputs for better UX and accessibility compliance. The Component property should match the Name property of the input it describes.

Declaration
public RadzenLabel()

Properties

ChildContentlink

Gets or sets custom child content to render as the label text. When set, overrides the Text property for displaying complex label content.

Declaration
public RenderFragment ChildContent { get; set; }
Property Value
Type Description
RenderFragmentGets or sets custom child content to render as the label text. When set, overrides the Text property for displaying complex label content.

Componentlink

Gets or sets the name of the input component this label is associated with. Must match the Name property of the target input component to create the proper label/input relationship. When set, clicking the label will focus the associated input.

Declaration
public string Component { get; set; }
Property Value
Type Description
stringGets or sets the name of the input component this label is associated with. Must match the Name property of the target input component to create the proper label/input relationship. When set, clicking the label will focus the associated input.

Textlink

Gets or sets the label text to display. For simple text labels, use this property. For complex content, use ChildContent instead.

Declaration
public string Text { get; set; }
Property Value
Type Description
stringGets or sets the label text to display. For simple text labels, use this property. For complex content, use ChildContent instead.

Methods

BuildRenderTreelink

Declaration
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
Parameters
Type Name Description
Rendering.RenderTreeBuilder __builder

GetComponentCssClasslink

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string
An error has occurred. This app may no longer respond until reloaded. Reload 🗙