# 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.

Namespace: [Radzen.Blazor](https://blazor.radzen.com/docs/api/Radzen.Blazor.md)

Assembly: Radzen.Blazor.dll

## Inheritance

- Object
- ComponentBase
- [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md)
- RadzenLabel

## Implements

- IComponent
- IHandleEvent
- IHandleAfterRender

## Syntax

```csharp
public class RadzenLabel : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender
```

## Examples

Basic label with input:

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

Label with custom content:

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

## Constructors

| Constructor | Description |
|-------------|-------------|
| `public RadzenLabel()` | 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. |

## Properties

| Property | Type | Description |
|------|------|-------------|
| ChildContent | `RenderFragment` | Gets or sets custom child content to render as the label text. When set, overrides the Text property for displaying complex label content. |
| Component | `string` | 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. |
| Text | `string` | Gets or sets the label text to display. For simple text labels, use this property. For complex content, use ChildContent instead. |
| TextStyle | `TextStyle?` | Gets or sets the typography style applied to the label, matching the presets available on [RadzenText](https://blazor.radzen.com/docs/api/Radzen.Blazor.RadzenText.md) (H1–H6, Subtitle1/2, Body1/2, Button, Caption, Overline, DisplayH1–H6). When null (default), no typography class is added and the label inherits the surrounding text styles. |

## Methods

| Method | Returns | Description |
|------|---------|-------------|
| `BuildRenderTree(Rendering.RenderTreeBuilder __builder)` | `void` |  |
| `GetComponentCssClass()` | `string` |  |

## Inherited Members

- From [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md): AddContextMenu, Attributes, ContextMenu, Culture, CurrentStyle, Debounce, DefaultCulture, DefaultUICulture, Dispose, Element, GetCssClass, GetId, GetIdAttribute, IsJSRuntimeAvailable, JSRuntime, Localize, MouseEnter, MouseLeave, OnAfterRenderAsync, OnBecameInvisible, OnContextMenu, OnInitialized, OnMouseEnter, OnMouseLeave, RaiseContextMenu, RaiseMouseEnter, RaiseMouseLeave, Reference, SetParametersAsync, Style, UICulture, UniqueID, Visible
- From ComponentBase: Assets, AssignedRenderMode, DispatchExceptionAsync, InvokeAsync, OnAfterRender, OnInitializedAsync, OnParametersSet, OnParametersSetAsync, RendererInfo, ShouldRender, StateHasChanged

