Composing with a form field
The normal way to use aegov-label is inside aegov-form-field, next to the control it names. The wrapper finds both, reads the control's field-id, and sets the label's for — no manual id-wiring needed. Clicking the label text moves focus to the paired control.
<aegov-form-field>
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae"></aegov-input>
</aegov-form-field>
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function LabelFormField() {
return (
<AegovFormField>
<AegovLabel>Email address</AegovLabel>
<AegovInput type="email" placeholder="name@example.ae" />
</AegovFormField>
);
}
<template>
<aegov-form-field>
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae"></aegov-input>
</aegov-form-field>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-label-form-field',
imports: [AegovFormField, AegovLabel, AegovInput],
template: `
<aegov-form-field>
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae"></aegov-input>
</aegov-form-field>
`,
})
export class LabelFormFieldComponent {}
Standalone use
Outside aegov-form-field, set for yourself, pointing at the control's field-id. Prefer the wrapper where you can — a hand-written for that drifts out of sync with the control's real id is easy to miss in review, since nothing visibly breaks.
<aegov-label for="applicant-name">Applicant name</aegov-label>
<aegov-input field-id="applicant-name" placeholder="Full legal name"></aegov-input>
import { AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function LabelStandalone() {
return (
<>
<AegovLabel htmlFor="applicant-name">Applicant name</AegovLabel>
<AegovInput fieldId="applicant-name" placeholder="Full legal name" />
</>
);
}
<template>
<aegov-label for="applicant-name">Applicant name</aegov-label>
<aegov-input field-id="applicant-name" placeholder="Full legal name"></aegov-input>
</template>
import { Component } from '@angular/core';
import { AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-label-standalone',
imports: [AegovLabel, AegovInput],
template: `
<aegov-label htmlFor="applicant-name">Applicant name</aegov-label>
<aegov-input field-id="applicant-name" placeholder="Full legal name"></aegov-input>
`,
})
export class LabelStandaloneComponent {}
Variant
variant sets the label's colour to match the control family it names, and cascades from aegov-form-field so setting it once on the wrapper covers the label and the control together. primary and secondary render identically (both a neutral aeblack-600) — the label itself doesn't take on the control's brand colour, only neutral-max/neutral-min shift its tone.
| Variant | Label colour |
|---|---|
primary |
aeblack-600 |
secondary |
aeblack-600 |
neutral-max |
aeblack-800 |
neutral-min |
aeblack-500 |
Required and optional markers
aegov-label has no is-required property. A required marker is content, so you author it yourself inside the label — that keeps you in control of its wording, colour, and what a screen reader announces. Hide a visual asterisk from assistive technology with aria-hidden="true", and add a visually hidden note so the requirement is still announced. Set the real, programmatic requirement on the control itself with is-required — the marker alone is not a substitute (WCAG 2.2 SC 1.4.1).
<aegov-form-field>
<aegov-label>
Emirates ID
<span class="text-aered-600" aria-hidden="true">*</span>
<span class="sr-only">(required)</span>
</aegov-label>
<aegov-input is-required="true" placeholder="784-YYYY-NNNNNNN-N"></aegov-input>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Middle name <span class="text-aeblack-400 font-normal">(optional)</span></aegov-label>
<aegov-input placeholder="Optional"></aegov-input>
</aegov-form-field>
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function LabelRequired() {
return (
<>
<AegovFormField>
<AegovLabel>
Emirates ID
<span className="text-aered-600" aria-hidden="true">*</span>
<span className="sr-only">(required)</span>
</AegovLabel>
<AegovInput isRequired placeholder="784-YYYY-NNNNNNN-N" />
</AegovFormField>
<AegovFormField>
<AegovLabel>Middle name <span className="text-aeblack-400 font-normal">(optional)</span></AegovLabel>
<AegovInput placeholder="Optional" />
</AegovFormField>
</>
);
}
<template>
<aegov-form-field>
<aegov-label>
Emirates ID
<span class="text-aered-600" aria-hidden="true">*</span>
<span class="sr-only">(required)</span>
</aegov-label>
<aegov-input is-required="true" placeholder="784-YYYY-NNNNNNN-N"></aegov-input>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Middle name <span class="text-aeblack-400 font-normal">(optional)</span></aegov-label>
<aegov-input placeholder="Optional"></aegov-input>
</aegov-form-field>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-label-required',
imports: [AegovFormField, AegovLabel, AegovInput],
template: `
<aegov-form-field>
<aegov-label>
Emirates ID
<span class="text-aered-600" aria-hidden="true">*</span>
<span class="sr-only">(required)</span>
</aegov-label>
<aegov-input [isRequired]="true" placeholder="784-YYYY-NNNNNNN-N"></aegov-input>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Middle name <span class="text-aeblack-400 font-normal">(optional)</span></aegov-label>
<aegov-input placeholder="Optional"></aegov-input>
</aegov-form-field>
`,
})
export class LabelRequiredComponent {}
RTL support
The label is direction-agnostic — it inherits text alignment from its container. A marker span placed after the label text renders on the inline-end side, which is the left in RTL, so the visual relationship to the field holds without any change to the markup.
<div dir="rtl">
<aegov-form-field>
<aegov-label>
الهوية الإماراتية
<span class="text-aered-600" aria-hidden="true">*</span>
<span class="sr-only">(مطلوب)</span>
</aegov-label>
<aegov-input is-required="true" placeholder="784-YYYY-NNNNNNN-N"></aegov-input>
</aegov-form-field>
</div>
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function RtlLabel() {
return (
<div dir="rtl">
<AegovFormField>
<AegovLabel>
الهوية الإماراتية
<span className="text-aered-600" aria-hidden="true">*</span>
<span className="sr-only">(مطلوب)</span>
</AegovLabel>
<AegovInput isRequired placeholder="784-YYYY-NNNNNNN-N" />
</AegovFormField>
</div>
);
}
<template>
<div dir="rtl">
<aegov-form-field>
<aegov-label>
الهوية الإماراتية
<span class="text-aered-600" aria-hidden="true">*</span>
<span class="sr-only">(مطلوب)</span>
</aegov-label>
<aegov-input is-required="true" placeholder="784-YYYY-NNNNNNN-N"></aegov-input>
</aegov-form-field>
</div>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-rtl-label',
imports: [AegovFormField, AegovLabel, AegovInput],
template: `
<div dir="rtl">
<aegov-form-field>
<aegov-label>
الهوية الإماراتية
<span class="text-aered-600" aria-hidden="true">*</span>
<span class="sr-only">(مطلوب)</span>
</aegov-label>
<aegov-input [isRequired]="true" placeholder="784-YYYY-NNNNNNN-N"></aegov-input>
</aegov-form-field>
</div>
`,
})
export class RtlLabelComponent {}
Usage
Here is the recommended usage of a label on any website or application. These are recommended usage guides, however the developer must use the best practices of web and application development to accurately use this component.
Give every control a visible, real label
A placeholder is not a label — it disappears on the first keystroke and is not reliably exposed as an accessible name. Pair every field with an aegov-label.
Keep the label short; put guidance in hint
A label is read out in full on every focus. "Emirates ID" is a name. Longer explanatory text belongs in the control's own hint, not the label.
Mark required state on the control itself, not just the label
An asterisk is purely visual. Set is-required on the paired control so the requirement is a real programmatic state, not just a glyph.
Don't use aegov-label for a group of controls
aegov-checkbox-group and aegov-radio-group render their own <fieldset>/<legend> pair — a single <label> cannot correctly name a group. Use the group's own label property instead.
Don't pair aegov-label with aegov-checkbox, aegov-radio, or aegov-toggle
Each of these already has its own inline label property that renders the label text correctly positioned beside the control — use that instead of a separate aegov-label.
API reference
The following are the properties and references of a label
aegov-label properties
| Attribute | Description | Type | Default |
|---|---|---|---|
| ID applied to the inner |
| auto-generated |
| ID of the control this label names. Set automatically when composed inside |
| — |
| Colour family. Cascades from |
|
|
| Extra CSS classes appended to the inner |
| — |
(none) | There is deliberately no |
Slots
| Slot | Description |
|---|---|
(default) | The label text, plus any required/optional marker markup you add. |
Pass-through attributes
| Attribute | Notes | Forwards to |
|---|---|---|
| Forwarded to the inner | inner |
| Forwarded to the inner | inner |
| Not forwarded. Use | n/a |
| Applied to the host element — stays host-only. Use | host |
Notes
The following notes are applicable of this component.
Built-in accessibility
- The inner element is a real native
<label>— clicking or tapping it moves focus to the paired control, using the browser's own nativefor/idresolution, not an ARIA substitute. - Inside
aegov-form-field,foris set from the control's generatedfield-idautomatically, so the association exists without you inventing IDs. variantcascades fromaegov-form-fieldwhen the two are composed together, so setting it once on the wrapper covers the label and the control.
Developer responsibilities
- Every control needs a visible, real label — a placeholder is not a substitute (see the "Don't" card above).
- Keep the label short; put longer guidance in the control's own
hint, not the label text. - Mark the real requirement on the control with
is-required— an asterisk in the label is a visual cue only, never a substitute for the programmatic state. - Verify
forpoints at a real, current id when usingaegov-labelstandalone — a stale or mistypedforis easy to miss in review, since nothing visibly breaks. - Use the group's own
labelproperty foraegov-checkbox-group/aegov-radio-group, and the control's own inlinelabelproperty foraegov-checkbox/aegov-radio/aegov-toggle—aegov-labelis for single, standalone controls composed viaaegov-form-field. - Don't put an interactive element (a link, a button) inside the label's slot — it creates two competing click targets. Place it after the field instead.
Keyboard support
The label itself is not a separate focus stop. Activating it — by click or tap — moves focus to its paired control, which is native <label> behaviour.