packages/components/eui-label/eui-label.component.ts
eui-label is a versatile textual component used to display labels, sublabels, or inline text associated with other UI elements such as inputs, form fields, or interactive components.
It supports multiple visual states, sizes, and variants through host directives and can be rendered as different HTML elements (<label>, <span>, <div>, <a>) while preserving consistent EUI styling and behavior.
The component is purely structural and semantic. It does not manage layout or interaction by itself.
<label euiLabel for="username">Username</label>
<input euiInputText id="username" /><label euiLabel [euiRequired]="true" for="email">Email Address</label><span euiLabel euiDanger>Error message</span>
<span euiLabel euiSuccess>Success message</span><label> element with for attribute to associate with form controls| changeDetection | ChangeDetectionStrategy.OnPush |
| HostDirectives |
BaseStatesDirective
Inputs : euiPrimary euiSecondary euiSuccess euiInfo euiWarning euiDanger euiVariant euiSizeS euiSizeM euiSizeL euiSizeVariant euiDisabled
|
| selector | label[euiLabel], span[euiLabel], div[euiLabel], a[euiLabel], eui-label,
label[euiSublabel], span[euiSublabel], div[euiSublabel], a[euiSublabel], eui-sublabel |
| template | |
| styleUrl | ./eui-label.scss |
Properties |
Inputs |
HostBindings |
Accessors |
| euiReadonly |
Type : boolean
|
Default value : false
|
| euiRequired |
Type : boolean
|
Default value : false
|
| euiSublabel |
Type : boolean
|
Default value : false
|
| class |
Type : string
|
|
Computes and returns the CSS classes for the label component based on its current state. Combines base states, required status, readonly status, and sublabel type. |
| baseStatesDirective |
Type : unknown
|
Default value : inject(BaseStatesDirective)
|
| cssClasses |
getcssClasses()
|
|
Computes and returns the CSS classes for the label component based on its current state. Combines base states, required status, readonly status, and sublabel type.
Returns :
string
|