Label

The name of a form control, with an optional required marker.

<x-atlas::label>

A label names one control, in bold, on its own line above it. It carries the whole label line: the name, a required marker, and anything else you put in the slot. Labels almost always live inside a field, which owns the spacing between the label and the control below it.

Company name
<x-atlas::field>
    <x-atlas::label for="company">Company name</x-atlas::label>
    <x-atlas::input id="company" name="company" type="text" />
</x-atlas::field>
Preview follows the site's light/dark mode. Open standalone →

Required marker

is-required appends a red asterisk, hidden from assistive technology so it is not read as punctuation. It is a visual cue only — the control still needs its own required attribute, and the browser will not enforce anything without it. Mark the minority: if most fields on a form are required, badge the optional ones instead.

VAT number Chamber of Commerce number
<x-atlas::field>
    <x-atlas::label for="vat-number" is-required>VAT number</x-atlas::label>
    <x-atlas::input id="vat-number" name="vat_number" type="text" placeholder="NL001234567B01" required />
</x-atlas::field>

<x-atlas::field>
    <x-atlas::label for="chamber-number">Chamber of Commerce number</x-atlas::label>
    <x-atlas::input id="chamber-number" name="chamber_number" type="text" />
</x-atlas::field>
Preview follows the site's light/dark mode. Open standalone →

Badge on the label line

Anything in the slot renders after the label text, which is where a badge goes when a field needs a qualifier a word longer than an asterisk — optional, beta, restricted to a role.

Referral code Optional API token Admins only
<x-atlas::field>
    <x-atlas::label for="referral-code">
        Referral code
        <x-atlas::badge variant="outlined" color="secondary">Optional</x-atlas::badge>
    </x-atlas::label>
    <x-atlas::input id="referral-code" name="referral_code" type="text" />
</x-atlas::field>

<x-atlas::field>
    <x-atlas::label for="api-token">
        API token
        <x-atlas::badge color="danger">Admins only</x-atlas::badge>
    </x-atlas::label>
    <x-atlas::input id="api-token" name="api_token" type="password" />
</x-atlas::field>
Preview follows the site's light/dark mode. Open standalone →

Pairing with the control

Atlas renders an <atlas-label> custom element rather than a native <label>, and nothing upgrades it in the browser. A for attribute therefore passes straight through to the markup without doing anything: clicking the label will not focus the control, and a screen reader will not announce the name.

Until that changes, give the label an id and point the control at it with aria-labelledby. Keeping for alongside it costs nothing and states the intent for whoever reads the template next.

Mobile number
<x-atlas::field>
    <x-atlas::label id="mobile-label" for="mobile">Mobile number</x-atlas::label>
    <x-atlas::input id="mobile" name="mobile" type="tel" aria-labelledby="mobile-label" placeholder="+31 6 12 34 56 78" />
</x-atlas::field>
Preview follows the site's light/dark mode. Open standalone →

Reference

<x-atlas::label>

  • Name
    is-required
    Type
    bool
    Default
    default: false
    Description
    Appends a red asterisk after the slot, hidden from assistive technology. Purely visual — it does not mark the control required.
  • Name
    badge
    Type
    string
    Default
    default: null
    Description
    Accepted but never rendered. Declaring it as a prop removes it from the attribute bag, so a value passed here disappears silently; put a <a href="/components/badge">badge</a> in the slot instead.

Slots

  • Name
    default
    Type
    slot
    Description
    The label text, and anything else that should sit on the label line.