Label
Renders an accessible label associated with form controls. Essential for form accessibility and usability.
Preview
A preview of the Label component with interactive controls.
Interactive
Installation
Add the Label component to your project.
ng g @ng-cn/core:c labelUsage
Import and use the Label component in your Angular application.
<div class="flex flex-col gap-2">
<Label htmlFor="username">Username</Label>
<Input type="text" id="username" placeholder="Enter username" />
</div>Examples
Explore different variations and use cases for the Label component.
Basic
A simple label associated with an input.
Interactive
With Form Control
Label properly associated with different form controls.
Interactive
Required Field Indicator
Show required field with visual indicator.
Interactive
Disabled State
Label styling when associated control is disabled.
Interactive
With Checkbox
Label inline with checkbox control.
Interactive
API Reference
Props | Prop | Type | Default | Description |
|---|---|---|---|
htmlFor | string | — | The id of the associated form element. |
class | string | — | Additional CSS classes. |