Composing with different controls
Drop an aegov-label and a supported control inside aegov-form-field; the label's for is set to the control's field-id on mount and on every update — nothing to wire by hand.
<aegov-form-field>
<aegov-label>Full name as on Emirates ID</aegov-label>
<aegov-input placeholder="Your full legal name"></aegov-input>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Reason for application</aegov-label>
<aegov-textarea placeholder="Briefly describe the purpose of your application." maxlength="500"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Emirate of residence</aegov-label>
<aegov-select placeholder="Select your emirate">
<aegov-select-option value="abu-dhabi">Abu Dhabi</aegov-select-option>
<aegov-select-option value="dubai">Dubai</aegov-select-option>
<aegov-select-option value="sharjah">Sharjah</aegov-select-option>
</aegov-select>
</aegov-form-field>
<aegov-form-field>
<aegov-label>I confirm that the information provided is true and accurate</aegov-label>
<aegov-checkbox></aegov-checkbox>
</aegov-form-field>
import { AegovFormField, AegovLabel, AegovInput, AegovTextarea, AegovSelect, AegovSelectOption, AegovCheckbox } from '@aegov/designsystem-react';
export default function FormFieldControls() {
return (
<>
<AegovFormField>
<AegovLabel>Full name as on Emirates ID</AegovLabel>
<AegovInput placeholder="Your full legal name" />
</AegovFormField>
<AegovFormField>
<AegovLabel>Reason for application</AegovLabel>
<AegovTextarea placeholder="Briefly describe the purpose of your application." maxlength={500} />
</AegovFormField>
<AegovFormField>
<AegovLabel>Emirate of residence</AegovLabel>
<AegovSelect placeholder="Select your emirate">
<AegovSelectOption value="abu-dhabi">Abu Dhabi</AegovSelectOption>
<AegovSelectOption value="dubai">Dubai</AegovSelectOption>
<AegovSelectOption value="sharjah">Sharjah</AegovSelectOption>
</AegovSelect>
</AegovFormField>
<AegovFormField>
<AegovLabel>I confirm that the information provided is true and accurate</AegovLabel>
<AegovCheckbox />
</AegovFormField>
</>
);
}
<template>
<aegov-form-field>
<aegov-label>Full name as on Emirates ID</aegov-label>
<aegov-input placeholder="Your full legal name"></aegov-input>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Reason for application</aegov-label>
<aegov-textarea placeholder="Briefly describe the purpose of your application." maxlength="500"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Emirate of residence</aegov-label>
<aegov-select placeholder="Select your emirate">
<aegov-select-option value="abu-dhabi">Abu Dhabi</aegov-select-option>
<aegov-select-option value="dubai">Dubai</aegov-select-option>
<aegov-select-option value="sharjah">Sharjah</aegov-select-option>
</aegov-select>
</aegov-form-field>
<aegov-form-field>
<aegov-label>I confirm that the information provided is true and accurate</aegov-label>
<aegov-checkbox></aegov-checkbox>
</aegov-form-field>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput, AegovTextarea, AegovSelect, AegovSelectOption, AegovCheckbox } from '@aegov/designsystem-angular';
@Component({
selector: 'app-form-field-controls',
imports: [AegovFormField, AegovLabel, AegovInput, AegovTextarea, AegovSelect, AegovSelectOption, AegovCheckbox],
template: `
<aegov-form-field>
<aegov-label>Full name as on Emirates ID</aegov-label>
<aegov-input placeholder="Your full legal name"></aegov-input>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Reason for application</aegov-label>
<aegov-textarea placeholder="Briefly describe the purpose of your application." maxlength="500"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
<aegov-label>Emirate of residence</aegov-label>
<aegov-select placeholder="Select your emirate">
<aegov-select-option value="abu-dhabi">Abu Dhabi</aegov-select-option>
<aegov-select-option value="dubai">Dubai</aegov-select-option>
<aegov-select-option value="sharjah">Sharjah</aegov-select-option>
</aegov-select>
</aegov-form-field>
<aegov-form-field>
<aegov-label>I confirm that the information provided is true and accurate</aegov-label>
<aegov-checkbox></aegov-checkbox>
</aegov-form-field>
`,
})
export class FormFieldControlsComponent {}
Composing a group
For aegov-checkbox-group and aegov-radio-group, skip aegov-form-field and name the group directly. Its own label property (rendered as the fieldset's <legend>) is the simplest option; aria-labelledby pointing at a plain heading beside it, as below, also works.
Which services do you need?
<h3 id="services-group-label" class="font-bold text-base">Which services do you need?</h3>
<div class="mt-2">
<aegov-checkbox-group aria-labelledby="services-group-label">
<aegov-checkbox field-id="cb-ff-visa" value="visa" label="Visa renewal"></aegov-checkbox>
<aegov-checkbox field-id="cb-ff-license" value="license" label="Driving license"></aegov-checkbox>
</aegov-checkbox-group>
</div>
import { AegovCheckboxGroup, AegovCheckbox } from '@aegov/designsystem-react';
export default function FormFieldGroup() {
return (
<>
<h3 id="services-group-label" className="font-bold text-base">Which services do you need?</h3>
<div className="mt-2">
<AegovCheckboxGroup aria-labelledby="services-group-label">
<AegovCheckbox fieldId="cb-ff-visa" value="visa" label="Visa renewal" />
<AegovCheckbox fieldId="cb-ff-license" value="license" label="Driving license" />
</AegovCheckboxGroup>
</div>
</>
);
}
<template>
<h3 id="services-group-label" class="font-bold text-base">Which services do you need?</h3>
<div class="mt-2">
<aegov-checkbox-group aria-labelledby="services-group-label">
<aegov-checkbox field-id="cb-ff-visa" value="visa" label="Visa renewal"></aegov-checkbox>
<aegov-checkbox field-id="cb-ff-license" value="license" label="Driving license"></aegov-checkbox>
</aegov-checkbox-group>
</div>
</template>
import { Component } from '@angular/core';
import { AegovCheckboxGroup, AegovCheckbox } from '@aegov/designsystem-angular';
@Component({
selector: 'app-form-field-group',
imports: [AegovCheckboxGroup, AegovCheckbox],
template: `
<h3 id="services-group-label" class="font-bold text-base">Which services do you need?</h3>
<div class="mt-2">
<aegov-checkbox-group aria-labelledby="services-group-label">
<aegov-checkbox field-id="cb-ff-visa" value="visa" label="Visa renewal"></aegov-checkbox>
<aegov-checkbox field-id="cb-ff-license" value="license" label="Driving license"></aegov-checkbox>
</aegov-checkbox-group>
</div>
`,
})
export class FormFieldGroupComponent {}
Helper and error text
aegov-form-field is a layout wrapper — a plain paragraph you place inside it renders below the control, but is not linked to it. Put helper text in the control's hint (or its hint slot) instead; the control renders it below the field and links it with aria-describedby. A hint on the wrapper cascades to the control in the same way, and an element in the wrapper's own hint slot is linked to the control automatically. The hint stays visible while an error shows.
<aegov-form-field>
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae" hint="We will use this address only to send service updates."></aegov-input>
</aegov-form-field>
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function FormFieldHelperText() {
return (
<AegovFormField>
<AegovLabel>Email address</AegovLabel>
<AegovInput type="email" placeholder="name@example.ae" hint="We will use this address only to send service updates." />
</AegovFormField>
);
}
<template>
<aegov-form-field>
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae" hint="We will use this address only to send service updates."></aegov-input>
</aegov-form-field>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-form-field-helper-text',
imports: [AegovFormField, AegovLabel, AegovInput],
template: `
<aegov-form-field>
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae" hint="We will use this address only to send service updates."></aegov-input>
</aegov-form-field>
`,
})
export class FormFieldHelperTextComponent {}
Required fields
Set is-required="true" on the inner control — it drives real HTML5 validation (the native required attribute) on the control itself. Neither aegov-form-field nor aegov-label render a required-indicator asterisk automatically; add your own visible cue in the label's own text if your form needs one.
<aegov-form-field>
<aegov-label>Emirates ID number *</aegov-label>
<aegov-input placeholder="784-XXXX-XXXXXXX-X" is-required="true"></aegov-input>
</aegov-form-field>
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function FormFieldRequired() {
return (
<AegovFormField>
<AegovLabel>Emirates ID number *</AegovLabel>
<AegovInput placeholder="784-XXXX-XXXXXXX-X" isRequired />
</AegovFormField>
);
}
<template>
<aegov-form-field>
<aegov-label>Emirates ID number *</aegov-label>
<aegov-input placeholder="784-XXXX-XXXXXXX-X" is-required="true"></aegov-input>
</aegov-form-field>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-form-field-required',
imports: [AegovFormField, AegovLabel, AegovInput],
template: `
<aegov-form-field>
<aegov-label>Emirates ID number *</aegov-label>
<aegov-input placeholder="784-XXXX-XXXXXXX-X" [isRequired]="true"></aegov-input>
</aegov-form-field>
`,
})
export class FormFieldRequiredComponent {}
Variant
variant set on aegov-form-field cascades to the linked aegov-label and to the first form-control descendant, when that descendant has no explicit variant of its own.
<aegov-form-field variant="primary">
<aegov-label>Primary</aegov-label>
<aegov-input placeholder="Inherits primary"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="secondary">
<aegov-label>Secondary</aegov-label>
<aegov-input placeholder="Inherits secondary"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="neutral-max">
<aegov-label>Neutral-max</aegov-label>
<aegov-input placeholder="Inherits neutral-max"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="neutral-min">
<aegov-label>Neutral-min</aegov-label>
<aegov-input placeholder="Inherits neutral-min"></aegov-input>
</aegov-form-field>
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function FormFieldVariants() {
return (
<>
<AegovFormField variant="primary">
<AegovLabel>Primary</AegovLabel>
<AegovInput placeholder="Inherits primary" />
</AegovFormField>
<AegovFormField variant="secondary">
<AegovLabel>Secondary</AegovLabel>
<AegovInput placeholder="Inherits secondary" />
</AegovFormField>
<AegovFormField variant="neutral-max">
<AegovLabel>Neutral-max</AegovLabel>
<AegovInput placeholder="Inherits neutral-max" />
</AegovFormField>
<AegovFormField variant="neutral-min">
<AegovLabel>Neutral-min</AegovLabel>
<AegovInput placeholder="Inherits neutral-min" />
</AegovFormField>
</>
);
}
<template>
<aegov-form-field variant="primary">
<aegov-label>Primary</aegov-label>
<aegov-input placeholder="Inherits primary"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="secondary">
<aegov-label>Secondary</aegov-label>
<aegov-input placeholder="Inherits secondary"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="neutral-max">
<aegov-label>Neutral-max</aegov-label>
<aegov-input placeholder="Inherits neutral-max"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="neutral-min">
<aegov-label>Neutral-min</aegov-label>
<aegov-input placeholder="Inherits neutral-min"></aegov-input>
</aegov-form-field>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-form-field-variants',
imports: [AegovFormField, AegovLabel, AegovInput],
template: `
<aegov-form-field variant="primary">
<aegov-label>Primary</aegov-label>
<aegov-input placeholder="Inherits primary"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="secondary">
<aegov-label>Secondary</aegov-label>
<aegov-input placeholder="Inherits secondary"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="neutral-max">
<aegov-label>Neutral-max</aegov-label>
<aegov-input placeholder="Inherits neutral-max"></aegov-input>
</aegov-form-field>
<aegov-form-field variant="neutral-min">
<aegov-label>Neutral-min</aegov-label>
<aegov-input placeholder="Inherits neutral-min"></aegov-input>
</aegov-form-field>
`,
})
export class FormFieldVariantsComponent {}
Composing with Card
A short group of form fields inside an aegov-card, for a self-contained step in a multi-step application.
Contact details
We'll use these to send updates about your application.
<aegov-card appearance="light">
<h3 class="font-bold text-lg m-0">Contact details</h3>
<p class="text-base mt-2">We'll use these to send updates about your application.</p>
<aegov-form-field extra-class="mt-4">
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae"></aegov-input>
</aegov-form-field>
<aegov-form-field extra-class="mt-4">
<aegov-label>Mobile number</aegov-label>
<aegov-input type="tel" placeholder="+971 5X XXX XXXX"></aegov-input>
</aegov-form-field>
</aegov-card>
import { AegovCard, AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-react';
export default function FormFieldCardPanel() {
return (
<AegovCard appearance="light">
<h3 className="font-bold text-lg m-0">Contact details</h3>
<p className="text-base mt-2">We'll use these to send updates about your application.</p>
<AegovFormField extraClass="mt-4">
<AegovLabel>Email address</AegovLabel>
<AegovInput type="email" placeholder="name@example.ae" />
</AegovFormField>
<AegovFormField extraClass="mt-4">
<AegovLabel>Mobile number</AegovLabel>
<AegovInput type="tel" placeholder="+971 5X XXX XXXX" />
</AegovFormField>
</AegovCard>
);
}
<template>
<aegov-card appearance="light">
<h3 class="font-bold text-lg m-0">Contact details</h3>
<p class="text-base mt-2">We'll use these to send updates about your application.</p>
<aegov-form-field extra-class="mt-4">
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae"></aegov-input>
</aegov-form-field>
<aegov-form-field extra-class="mt-4">
<aegov-label>Mobile number</aegov-label>
<aegov-input type="tel" placeholder="+971 5X XXX XXXX"></aegov-input>
</aegov-form-field>
</aegov-card>
</template>
import { Component } from '@angular/core';
import { AegovCard, AegovFormField, AegovLabel, AegovInput } from '@aegov/designsystem-angular';
@Component({
selector: 'app-form-field-card-panel',
imports: [AegovCard, AegovFormField, AegovLabel, AegovInput],
template: `
<aegov-card appearance="light">
<h3 class="font-bold text-lg m-0">Contact details</h3>
<p class="text-base mt-2">We'll use these to send updates about your application.</p>
<aegov-form-field extra-class="mt-4">
<aegov-label>Email address</aegov-label>
<aegov-input type="email" placeholder="name@example.ae"></aegov-input>
</aegov-form-field>
<aegov-form-field extra-class="mt-4">
<aegov-label>Mobile number</aegov-label>
<aegov-input type="tel" placeholder="+971 5X XXX XXXX"></aegov-input>
</aegov-form-field>
</aegov-card>
`,
})
export class FormFieldCardPanelComponent {}
RTL support
aegov-form-field is a thin block-level wrapper with no horizontal directional styling of its own — it renders identically in LTR and RTL. Wrap the form (or its container) with dir="rtl" and every linked label, control, and helper text follows the surrounding direction.
<div dir="rtl">
<aegov-form-field>
<aegov-label>الاسم الكامل كما في الهوية الإماراتية</aegov-label>
<aegov-input is-required="true" placeholder="الاسم الكامل"></aegov-input>
</aegov-form-field>
<aegov-form-field extra-class="mt-4">
<aegov-label>إمارة الإقامة</aegov-label>
<aegov-select placeholder="اختر الإمارة">
<aegov-select-option value="abu-dhabi">أبوظبي</aegov-select-option>
<aegov-select-option value="dubai">دبي</aegov-select-option>
<aegov-select-option value="sharjah">الشارقة</aegov-select-option>
</aegov-select>
</aegov-form-field>
</div>
import { AegovFormField, AegovLabel, AegovInput, AegovSelect, AegovSelectOption } from '@aegov/designsystem-react';
export default function RtlFormField() {
return (
<div dir="rtl">
<AegovFormField>
<AegovLabel>الاسم الكامل كما في الهوية الإماراتية</AegovLabel>
<AegovInput isRequired placeholder="الاسم الكامل" />
</AegovFormField>
<AegovFormField extraClass="mt-4">
<AegovLabel>إمارة الإقامة</AegovLabel>
<AegovSelect placeholder="اختر الإمارة">
<AegovSelectOption value="abu-dhabi">أبوظبي</AegovSelectOption>
<AegovSelectOption value="dubai">دبي</AegovSelectOption>
<AegovSelectOption value="sharjah">الشارقة</AegovSelectOption>
</AegovSelect>
</AegovFormField>
</div>
);
}
<template>
<div dir="rtl">
<aegov-form-field>
<aegov-label>الاسم الكامل كما في الهوية الإماراتية</aegov-label>
<aegov-input is-required="true" placeholder="الاسم الكامل"></aegov-input>
</aegov-form-field>
<aegov-form-field extra-class="mt-4">
<aegov-label>إمارة الإقامة</aegov-label>
<aegov-select placeholder="اختر الإمارة">
<aegov-select-option value="abu-dhabi">أبوظبي</aegov-select-option>
<aegov-select-option value="dubai">دبي</aegov-select-option>
<aegov-select-option value="sharjah">الشارقة</aegov-select-option>
</aegov-select>
</aegov-form-field>
</div>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovInput, AegovSelect, AegovSelectOption } from '@aegov/designsystem-angular';
@Component({
selector: 'app-rtl-form-field',
imports: [AegovFormField, AegovLabel, AegovInput, AegovSelect, AegovSelectOption],
template: `
<div dir="rtl">
<aegov-form-field>
<aegov-label>الاسم الكامل كما في الهوية الإماراتية</aegov-label>
<aegov-input [isRequired]="true" placeholder="الاسم الكامل"></aegov-input>
</aegov-form-field>
<aegov-form-field extra-class="mt-4">
<aegov-label>إمارة الإقامة</aegov-label>
<aegov-select placeholder="اختر الإمارة">
<aegov-select-option value="abu-dhabi">أبوظبي</aegov-select-option>
<aegov-select-option value="dubai">دبي</aegov-select-option>
<aegov-select-option value="sharjah">الشارقة</aegov-select-option>
</aegov-select>
</aegov-form-field>
</div>
`,
})
export class RtlFormFieldComponent {}
Usage
Here is the recommended usage of a form field 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.
Place exactly one label and one control inside each wrapper
If you need more than one input on a row, use multiple aegov-form-fields side by side rather than nesting extra controls in one — only the first matching control ever gets linked.
Put helper text in the control''s hint
Set hint (or fill the hint slot) on the control, or set hint (or fill the hint slot) on the wrapper. Either way it is linked with aria-describedby for you; a plain paragraph placed beside the control is not.
Use is-required on the control itself, not just visual styling
is-required="true" on the inner control drives real HTML5 validation (required on the native element) — it is the source of truth a form's own validation should key off, not a label convention alone.
Don't expect a required-field asterisk to appear automatically
Neither aegov-label nor aegov-form-field render a "*" for a required control — add your own visible indicator (e.g. appending an asterisk to the label's own text, or a "(required)" suffix) if your form needs one.
Don't compose aegov-checkbox-group or aegov-radio-group expecting an automatic label link
Automatic for/id linking only covers the control types listed in the "Supported controls" table above — neither group control is among them, because each renders its own <fieldset> and <legend>. Name the group with its own label property (or aria-labelledby pointing at a heading's id). The wrapper still cascades is-invalid, error-message, hint and variant to them.
API reference
The following are the properties and references of a form field
aegov-form-field properties
| Attribute | Description | Type | Default |
|---|---|---|---|
| DOM |
| auto-generated |
| Wrapper-level invalid state. Cascades to the first form-control descendant if the child has not set its own value; setting it back to |
|
|
| Wrapper-level error message. Cascades to the first form-control descendant if the child has no own value; changing or clearing it updates the cascaded value. |
|
|
| Wrapper-level hint text. Cascades to the first form-control descendant if the child has no own value; changing or clearing it updates the cascaded value. |
|
|
| Colour family. Cascades to the linked |
|
|
| Additional CSS classes appended to the wrapper |
| none |
Slots
| Slot | Description |
|---|---|
(default) | One |
| Named hint slot, rendered below the control. Useful for rich hint markup instead of the plain-text |
Pass-through attributes
| Attribute | Notes | Forwards to |
|---|---|---|
| Forwarded to the wrapper | wrapper |
| Forwarded to the wrapper | wrapper |
| Not forwarded. Use | n/a |
| Stay on the | host |
Notes
The following notes are applicable of this component.
Built-in accessibility
- After mount and on every update, the wrapper queries its slotted children for an
aegov-labeland a supported control (see the "Supported controls" table above). When both are present, the control's host gets itsfield-idasidand the label'sforpoints at it, so clicking the label focuses the control. - Because
<label for>cannot reach inside a control's shadow root, the wrapper also setsaria-labelon the control from the label's text, as a screen reader would read it — content markedaria-hidden="true"(such as a decorative "*") is skipped — and keeps it in sync when the label text changes. Anaria-labeloraria-labelledbyyou set on the control yourself is never overwritten. - When the linked control is disabled (by its own
is-disabledor an ancestor<fieldset disabled>), the label is dimmed to match. - The wrapper preserves user-set
aria-*/data-*attributes via pass-through, sorole="group"plusaria-labelledbycan be added when grouping multiple controls. - The wrapper itself has no implicit ARIA role — assistive technology treats it as a plain
<div>.
Developer responsibilities
- Place exactly one
aegov-labeland one supported control inside each form-field.aegov-checkbox-groupandaegov-radio-groupnever get a label link — name them with their ownlabelproperty, oraria-labelledby(see "Composing a group" above). - For helper or error text, use the control's
hintanderror-message(or their slots), or set them (or thehintslot) on the wrapper — they are linked witharia-describedbyautomatically. A separate paragraph is not linked automatically. - Set
is-requiredon the inner control for real HTML5 validation; add your own visible required-indicator in the label's text, since neither the label nor the wrapper render one automatically. - Do not nest one
aegov-form-fieldinside another; with several controls in one wrapper, only the first is linked and receives the cascade.
Keyboard support
aegov-form-field introduces no keyboard behaviour of its own. All keyboard interaction is handled by the inner control — refer to that control's own documentation for its keyboard map.