Docs

Main site

Installation Browser support Extend config MCP server
Validation Page speed testing Responsive design
Accordion Aspect Ratio Avatar Badge Banner Bento Grid Blockquote Breadcrumbs Button Callout Card Drawer Dropdown Link Modal Navbar Navblock Pagination Popover Progress Separator Tabs Timeline Toast Tooltip
Checkbox Datepicker File upload Form field Input Label OTP Radio Range Select Textarea Toggle
Header Footer
Accordion Auth Checkbox & Radio Content Drawers Features Modals Statistics & Metrics Teams
Address Contact number Currency symbol Date Emirates ID Name
Close
Home Documentation Components Label

Label

A Label names a form control, giving it both an accessible name for assistive technology and a click target that focuses the field for sighted users. "aegov-label" renders a real native label element and, when placed inside "aegov-form-field", has its "for" attribute wired to the paired control automatically.

label form accessibility
Status
Active
Introduced
4.0.x
View source code

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.

Email address
<aegov-form-field>
  <aegov-label>Email address</aegov-label>
  <aegov-input type="email" placeholder="name@example.ae"></aegov-input>
</aegov-form-field>

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.

Applicant name
<aegov-label for="applicant-name">Applicant name</aegov-label>
<aegov-input field-id="applicant-name" placeholder="Full legal name"></aegov-input>

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

Emirates ID (required) Middle name (optional)
<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>

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>

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

AttributeDescriptionTypeDefault

field-id

ID applied to the inner <label>. Auto-generated when omitted, reflected onto the host.

string

auto-generated

for

ID of the control this label names. Set automatically when composed inside aegov-form-field; set it yourself for standalone use.

string

—

variant

Colour family. Cascades from aegov-form-field when composed together.

primary | secondary | neutral-max | neutral-min

primary

extra-class

Extra CSS classes appended to the inner <label>.

string

—

(none)

There is deliberately no is-required property — see Required and optional markers below.

Slots

SlotDescription

(default)

The label text, plus any required/optional marker markup you add.

Pass-through attributes

AttributeNotesForwards to

aria-*

Forwarded to the inner <label>.

inner <label>

data-*

Forwarded to the inner <label>.

inner <label>

id

Not forwarded. Use field-id — it sets the inner <label>'s real id.

n/a

class, style

Applied to the host element — stays host-only. Use extra-class to reach the inner <label> itself.

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 native for/id resolution, not an ARIA substitute.
  • Inside aegov-form-field, for is set from the control's generated field-id automatically, so the association exists without you inventing IDs.
  • variant cascades from aegov-form-field when 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 for points at a real, current id when using aegov-label standalone — a stale or mistyped for is easy to miss in review, since nothing visibly breaks.
  • Use the group's own label property for aegov-checkbox-group/aegov-radio-group, and the control's own inline label property for aegov-checkbox/aegov-radio/aegov-toggle — aegov-label is for single, standalone controls composed via aegov-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.