GUILD OF GLEKS UIv21.4.4

gog-inputfield

Input Field

A text field with five sizes, leading/trailing icons that can double as buttons, a built-in password reveal toggle, and full ControlValueAccessor support.

Overview

Import the component and drop it into a template.

typescript
import { InputfieldComponent } from '@guildofgleks/ui';

@Component({
  // ...
  imports: [InputfieldComponent],
})

Basic usage — a labeled field bound with [(value)]:

<gog-inputfield label="Name" placeholder="Ada Lovelace" [(value)]="name" />

Examples

Sizes

Five size steps, from xsm to slg.

@for (sizeOption of sizes; track sizeOption) {
  <gog-inputfield [size]="sizeOption" [label]="sizeOption" [placeholder]="sizeOption" />
}

Password

type="password" gets a built-in show/hide toggle for free — the trailing icon and its accessible label switch automatically.

<gog-inputfield label="Password" type="password" [(value)]="password" />

Icons

iconStart / iconEnd take a bare icon name — the genuinely common case, and the whole API for a decorative icon.

<gog-inputfield label="Search" iconStart="info" placeholder="Decorative start icon" />

Addon slots

For anything more than an icon name, project a gogInputAddonStart or gogInputAddonEnd element. Because it takes arbitrary markup, an actionable addon is a real <button> carrying its own aria-label and (click) — nothing has to be threaded through the field.

$USD

No icon action yet.

<gog-inputfield label="Amount" [(value)]="amount">
  <span gogInputAddonStart>$</span>
  <span gogInputAddonEnd>USD</span>
</gog-inputfield>

<gog-inputfield label="Search" [(value)]="search">
  <button type="button" gogInputAddonEnd aria-label="Clear search" (click)="clearSearch()">
    <gog-icon name="close" />
  </button>
</gog-inputfield>

These two slots replace six inputs — iconStartTemplate, iconEndTemplate, iconStartFn, iconEndFn, iconStartLabel and iconEndLabel — all deprecated in 21.3.0 and removed in 21.5.0. iconStart and iconEnd stay.

html
<!-- 21.2.x — three inputs to get one actionable trailing icon -->
<gog-inputfield
  label="Search"
  iconEnd="close"
  iconEndLabel="Clear search"
  [iconEndFn]="clearSearch"
  [(value)]="search"
/>

<!-- 21.3.0 — a real button, with its own aria-label and (click) -->
<gog-inputfield label="Search" [(value)]="search">
  <button type="button" gogInputAddonEnd aria-label="Clear search" (click)="clearSearch()">
    <gog-icon name="close" />
  </button>
</gog-inputfield>

<!-- …or just let the component do it -->
<gog-inputfield label="Search" [clearable]="true" [(value)]="search" />

Clearable

The built-in clear button is value-driven: it appears once there is something to clear and vanishes when there isn't. It replaces the hand-rolled trailing-icon-plus-callback pattern entirely. On a type="password" field the reveal toggle keeps the trailing slot, so the only control that shows the value can never be displaced.

<gog-inputfield label="Search" [clearable]="true" [(value)]="search" />

Float label

floatLabel rests the label inside the field like a placeholder and floats it up on focus or once the field has content. The three variants differ only in where it lands: in stays inside the border, on centres on the top border line, and over floats fully above it. Also settable app-wide through GOG_CONFIG.floatLabel.

<gog-inputfield label="in" floatLabel="in" />
<gog-inputfield label="on" floatLabel="on" />
<gog-inputfield label="over" floatLabel="over" />

Error message

errorDisplay="manual" (the default) shows errorMessage for as long as it's non-empty — you own the timing. Type fewer than 3 characters to see it.

<gog-inputfield
  label="Username"
  [(value)]="manualErrorValue"
  [errorMessage]="manualErrorValue().length > 0 && manualErrorValue().length < 3 ? 'At least 3 characters' : ''"
/>

Reactive Forms

Wire it to a FormControl with [formControl] instead of [(value)]. With errorDisplay="auto", the error only shows once the control has been touched and is invalid — blur the empty field to see it.

<gog-inputfield
  label="Email"
  [formControl]="emailControl"
  errorMessage="Enter a valid email"
  errorDisplay="auto"
/>

Number and date

type="number" accepts min/max/step; wired to a formControl, its value is a real number (null when empty) rather than the raw string [(value)] would give you. type="date" renders the native date picker.

Quantity (number): 1 — Delivery date (string): ""

<gog-inputfield
  label="Quantity"
  type="number"
  [min]="1"
  [max]="10"
  [step]="1"
  [formControl]="quantityControl"
/>

<gog-inputfield label="Delivery date" type="date" [(value)]="deliveryDate" />

Number spin buttons 21.3.1

A type="number" field renders the library's own +/ glyphs instead of the browser's, so they follow the theme and are the same size in every browser. [showSpinButtons]="false" removes them — the field still steps with the arrow keys and the mouse wheel, because that is native <input type="number"> behaviour and unrelated to which glyphs are visible. Set it app-wide with GOG_CONFIG.inputfield.showSpinButtons; incrementLabel/decrementLabel (or GOG_CONFIG.labels) name them for assistive tech.

The third field is worth a look: clearable and the stepper now coexist21.3.2. The clear button sits to the left of the stepper and the gutter widens for the pair. Before that, clearable was silently a no-op on type="number" unless showSpinButtons was also off — so any workaround built around that can go.

<gog-inputfield label="Quantity (stepper)" type="number" [min]="0" [(value)]="quantity" />

<gog-inputfield
  label="Quantity (no stepper)"
  type="number"
  [min]="0"
  [showSpinButtons]="false"
  [(value)]="quantity"
/>

<gog-inputfield
  label="Weight (clearable + stepper)"
  type="number"
  [min]="0"
  [clearable]="true"
  [(value)]="weight"
/>

Disabled

<gog-inputfield label="Disabled" [disabled]="true" value="Read only" />

Auto width

Fields fill their container by default; fullWidth="false" shrinks the field to fit its content instead.

<gog-inputfield label="Zip code" [fullWidth]="false" placeholder="00000" />

API Reference

Inputs

NameTypeDefaultDescription
showSpinButtons21.3.1boolean | undefinedundefinedWhether a type="number" field shows the library's own +/- glyphs in place of the browser's native ones. Off, the field still steps with the arrow keys and the mouse wheel — that is native behaviour, unrelated to which glyphs are visible. Unset, falls back to GOG_CONFIG.inputfield.showSpinButtons, then to true.
incrementLabel / decrementLabel21.3.1string | undefined'Increment' / 'Decrement'Accessible names for the two spin buttons. Also via GOG_CONFIG.labels.
readonly21.3.2booleanfalseBlocks edits while keeping the value focusable, selectable and submitted with the form. Hides both the clear button and the stepper.
maxlength21.3.2number | nullnullNative maxlength attribute.
minlength21.3.2number | nullnullNative minlength attribute.
pattern21.3.2string''Native pattern attribute — a regular expression source, not a literal.
inputMode21.3.2GogInputMode | nullnullOn-screen keyboard hint ('numeric', 'tel', 'decimal', …). Worth setting on a numeric field so a phone offers the right keypad.
spellcheck21.3.2boolean | nullnullNative spellcheck attribute. Unset leaves the browser's own default in place.
valuestring (model)''Two-way bindable value via [(value)]. Always a string — even for type="number" — since it mirrors the native input's raw text. Also the value Angular Forms drives through writeValue/registerOnChange when used with formControlName/[formControl]/ngModel; there, a number field's value is a number (null when empty) instead.
labelstring''Field label.
placeholderstring''Native placeholder text.
type'text' | 'password' | 'email' | 'number' | 'date''text'Native input type. password gets a built-in show/hide toggle for free.
min / max / stepnumber | nullnullOnly applied when type="number" — forwarded to the native min/max/step attributes.
autocompletestring''Forwarded to the native input. Defaults to 'current-password' for password fields, 'off' otherwise, when left empty.
errorMessagestring''Error text to display. Visibility is governed by errorDisplay.
errorDisplay'auto' | 'manual''manual''manual': shown for as long as errorMessage is non-empty — you decide the timing. 'auto': shown once the attached FormControl is touched and invalid; falls back to manual without one.
namestring''Native name attribute.
inputIdstring''id on the native input, and target of the label's for attribute.
disabledbooleanfalseDisables the native input.
size'xsm' | 'sm' | 'md' | 'lg' | 'slg''md'Field height, padding, and font size.
fullWidthbooleantrueFills its container by default. Set false to shrink to content width instead.
iconStart / iconEndGogIconName | ''''Leading / trailing icon name.
clearablebooleanGOG_CONFIG.control.clearable ?? falseAdds a clear button. It appears only once the field has something to clear and disappears again when empty, so it adds no permanent chrome. On a password field the built-in reveal toggle keeps the trailing slot.
clearAriaLabelstring'Clear'Accessible name for that clear button.
floatLabel'none' | 'in' | 'on' | 'over'GOG_CONFIG.floatLabel.variant ?? 'none'Rests the label inside the field like a placeholder and floats it up on focus or once the field has content. 'in' stays inside the border, 'on' centres on the top border line, 'over' floats fully above it.
floatLabelShowPlaceholderbooleanGOG_CONFIG.floatLabel.showPlaceholder ?? falseReveals the field’s own placeholder once the label has floated out of the way. Off by default, since the resting label already occupies that space.
showPasswordLabel / hidePasswordLabelstring'Show password' / 'Hide password'Accessible labels for the built-in password reveal toggle.

Content slots

SlotDescription
[gogInputAddonStart]Arbitrary markup in the leading slot — text, an icon, or a real button.
[gogInputAddonEnd] The same in the trailing slot. On type="password" the built-in reveal toggle keeps this slot, so a projected addon can never displace the only control that shows the value.

Deprecated in 21.3.0

Six inputs collapsed into the two addon slots above. They keep working until they are removed in 21.5.0, and a projected addon wins over them — so a codebase can migrate one field at a time. iconStart and iconEnd are not deprecated: a bare icon name is the genuinely common case.

NameTypeDefaultDescription
iconStartTemplate / iconEndTemplateTemplateRef<unknown> | nullnullCustom leading / trailing icon, in place of iconStart / iconEnd.
iconStartFn / iconEndFn(() => void) | nullnullWhen set, the icon became a clickable button invoking this function.
iconStartLabel / iconEndLabelstring''Accessible label for that icon button — required when the matching *Fn was set.

Styling Tokens

Every CSS custom property the input field paints with. Override any of them — on a single instance, a subtree, or a theme — to restyle it. See the Theming guide for the full token-layering model, or the Theme Generator to tweak these live.

TokenDescription
--gog-input-label-colorField label color.
--gog-input-field-bg / -field-border / -field-colorField surface, border and text.
--gog-input-radiusField corner radius.
--gog-input-focus-border / -focus-ring / -focus-glowFocus state.
--gog-input-error-colorValidation error color.
--gog-input-icon-color / -icon-hover-colorPrefix / suffix icon color.
--gog-input-float-label-reserve / -in-top / -on-bg / -over-gap / -over-reserveFloat-label geometry, derived from the shared --gog-field-float-label-* scale. -on-bg is an instance-layer token (undeclared) — the patch that masks the border behind an "on" label.
--gog-textarea-clear-icon-ratioSize of gog-textarea’s clear glyph relative to the field. A textarea is a large multi-line box, so it takes a full-size glyph rather than the dropdowns’ denser 0.7 ratio.
--gog-textarea-scrollbar-widthInstance-layer (undeclared): written by the component from its own measured scrollbar width, so a clear button on a scrolling textarea does not end up under the thumb.