Sizes
Five size steps, from xsm to slg.
@for (sizeOption of sizes; track sizeOption) {
<gog-inputfield [size]="sizeOption" [label]="sizeOption" [placeholder]="sizeOption" />
}gog-inputfield
A text field with five sizes, leading/trailing icons that can double as buttons, a built-in password reveal toggle, and full ControlValueAccessor support.
Import the component and drop it into a template.
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" />Value: ""
Five size steps, from xsm to slg.
@for (sizeOption of sizes; track sizeOption) {
<gog-inputfield [size]="sizeOption" [label]="sizeOption" [placeholder]="sizeOption" />
}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" />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" /> 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.
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.
<!-- 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" />
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" />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" />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' : ''"
/> 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"
/>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" /> 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 coexistclearable 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"
/><gog-inputfield label="Disabled" [disabled]="true" value="Read only" /> 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" />| Name | Type | Default | Description |
|---|---|---|---|
showSpinButtons | boolean | undefined | undefined | Whether 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 / decrementLabel | string | undefined | 'Increment' / 'Decrement' | Accessible names for the two spin buttons. Also via GOG_CONFIG.labels. |
readonly | boolean | false | Blocks edits while keeping the value focusable, selectable and submitted with the form. Hides both the clear button and the stepper. |
maxlength | number | null | null | Native maxlength attribute. |
minlength | number | null | null | Native minlength attribute. |
pattern | string | '' | Native pattern attribute — a regular expression source, not a literal. |
inputMode | GogInputMode | null | null | On-screen keyboard hint ('numeric', 'tel', 'decimal', …). Worth setting on a numeric field so a phone offers the right keypad. |
spellcheck | boolean | null | null | Native spellcheck attribute. Unset leaves the browser's own default in place. |
value | string (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. |
label | string | '' | Field label. |
placeholder | string | '' | 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 / step | number | null | null | Only applied when type="number" — forwarded to the native min/max/step attributes. |
autocomplete | string | '' | Forwarded to the native input. Defaults to 'current-password' for password fields, 'off' otherwise, when left empty. |
errorMessage | string | '' | 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. |
name | string | '' | Native name attribute. |
inputId | string | '' | id on the native input, and target of the label's for attribute. |
disabled | boolean | false | Disables the native input. |
size | 'xsm' | 'sm' | 'md' | 'lg' | 'slg' | 'md' | Field height, padding, and font size. |
fullWidth | boolean | true | Fills its container by default. Set false to shrink to content width instead. |
iconStart / iconEnd | GogIconName | '' | '' | Leading / trailing icon name. |
clearable | boolean | GOG_CONFIG.control.clearable ?? false | Adds 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. |
clearAriaLabel | string | '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. |
floatLabelShowPlaceholder | boolean | GOG_CONFIG.floatLabel.showPlaceholder ?? false | Reveals 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 / hidePasswordLabel | string | 'Show password' / 'Hide password' | Accessible labels for the built-in password reveal toggle. |
| Slot | Description |
|---|---|
[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. |
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.
| Name | Type | Default | Description |
|---|---|---|---|
iconStartTemplate / iconEndTemplate | TemplateRef<unknown> | null | null | Custom leading / trailing icon, in place of iconStart / iconEnd. |
iconStartFn / iconEndFn | (() => void) | null | null | When set, the icon became a clickable button invoking this function. |
iconStartLabel / iconEndLabel | string | '' | Accessible label for that icon button — required when the matching *Fn was set. |
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.
| Token | Description |
|---|---|
--gog-input-label-color | Field label color. |
--gog-input-field-bg / -field-border / -field-color | Field surface, border and text. |
--gog-input-radius | Field corner radius. |
--gog-input-focus-border / -focus-ring / -focus-glow | Focus state. |
--gog-input-error-color | Validation error color. |
--gog-input-icon-color / -icon-hover-color | Prefix / suffix icon color. |
--gog-input-float-label-reserve / -in-top / -on-bg / -over-gap / -over-reserve | Float-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-ratio | Size 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-width | Instance-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. |