Sizes
Five steps, also settable app-wide through GOG_CONFIG.control.size.
@for (size of sizes; track size) {
<gog-inputfield [size]="size" [label]="size" placeholder="Placeholder" />
}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 labelled field bound with [(value)]. The value is the string in the field; valueChange fires on every keystroke.
value: "" · 0 valueChange<div>
<gog-inputfield
label="Name"
placeholder="Ada Lovelace"
[(value)]="name"
(valueChange)="changes.update((n) => n + 1)"
/>
<code>value: "{{ name() }}" · {{ changes() }} valueChange</code>
</div> Five steps, also settable app-wide through GOG_CONFIG.control.size.
@for (size of sizes; track size) {
<gog-inputfield [size]="size" [label]="size" placeholder="Placeholder" />
} Default, disabled, readonly and with an error. readonly keeps the field focusable and its text selectable; disabled takes it out of the tab order and dims the whole field — label, box, icons and addons — as one piece
<gog-inputfield label="Default" placeholder="Placeholder" />
<gog-inputfield label="Disabled" value="Value" disabled />
<!-- readonly: focusable and selectable, but not editable. -->
<gog-inputfield label="Readonly" value="Value" readonly />
<gog-inputfield label="Error" errorMessage="Required field" />type is forwarded to the native input, so each of these brings the browser's own keyboard, validation and pickers — the date and time types render the native picker. password and number gain the library's own controls, below.
@for (type of types; track type.type) {
<gog-inputfield [type]="type.type" [label]="type.type" [placeholder]="type.placeholder" />
}iconStart / iconEnd take a bare icon name — the common case, and the whole API for a decorative icon: it renders an aria-hidden span, never a button.
<!-- A bare icon name: decorative, an aria-hidden span, never a button. -->
<gog-inputfield label="Search" iconStart="search" placeholder="Search…" />
<gog-inputfield label="Favourite" iconEnd="star" placeholder="Item" /> 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> with its own aria-label and (click) — nothing threaded through the field. The field measures each addon and makes room for it https:// no longer runs under the typed text.
No search yet.<gog-inputfield label="Amount" [(value)]="amount">
<span gogInputAddonStart>$</span>
<span gogInputAddonEnd>USD</span>
</gog-inputfield>
<!-- The field makes room for an addon wider than an icon. -->
<gog-inputfield label="Website" [(value)]="website">
<span gogInputAddonStart>https://</span>
</gog-inputfield>
<!-- An actionable addon is a real button with its own name and click. -->
<div>
<gog-inputfield label="Search" [(value)]="search">
<button type="button" gogInputAddonEnd aria-label="Run search" (click)="run()">
<gog-icon name="search" />
</button>
</gog-inputfield>
<code>{{ lastSearch() }}</code>
</div>The built-in clear button is value-driven: it appears once there is something to clear and goes when there is not — replacing the hand-rolled trailing-icon-plus-callback pattern.
<!-- Appears once there is something to clear, and goes when there is not. -->
<gog-inputfield label="Name" clearable [(value)]="name" />
<gog-inputfield label="Empty" placeholder="Type to see it" clearable />type="password" gets a show/hide toggle; its icon and accessible label switch with the state. The toggle keeps the outer edge, and an iconEnd or a gogInputAddonEnd renders beside it
<gog-inputfield type="password" label="Password" value="secret" />
<!-- The reveal toggle keeps the outer edge; iconEnd or an addon sits beside it. -->
<gog-inputfield type="password" label="With iconEnd" iconEnd="lock" value="secret" />
<gog-inputfield type="password" label="With an addon" value="secret">
<span gogInputAddonEnd>PIN</span>
</gog-inputfield> A type="number" field draws the library's own +/−, so they follow the theme and are the same size in every browser; at min or max the button for that direction is disabled. [showSpinButtons]="false" removes them, and the field still steps with the arrow keys and the wheel — that is native behaviour. clearable and the stepper coexist: the clear button sits inside the stepper and the gutter widens for both.
<gog-inputfield type="number" label="Stepper" value="5" />
<!-- The arrow keys and the wheel still step: that is native number-input behaviour. -->
<gog-inputfield type="number" label="No stepper" [showSpinButtons]="false" value="5" />
<!-- At a bound the button for that direction is disabled. -->
<gog-inputfield
type="number"
label="At max (0–10, step 2)"
[min]="0"
[max]="10"
[step]="2"
value="10"
/>
<gog-inputfield
type="number"
label="At min (0–10, step 2)"
[min]="0"
[max]="10"
[step]="2"
value="0"
/>
<gog-inputfield type="number" label="Clearable and stepper" clearable value="5" /> The stepper keeps the outer edge, and an iconEnd or a unit addon sits beside it
<gog-inputfield type="number" label="iconEnd" iconEnd="star" value="5" />
<gog-inputfield type="number" label="Unit" value="5">
<span gogInputAddonEnd>kg</span>
</gog-inputfield>
<!-- While there is a value, the clear button takes the place beside the stepper. -->
<gog-inputfield type="number" label="Clear wins" clearable iconEnd="star" value="5" /> Through a formControl a number field's value is a real number (null when empty). [(value)] always hands back the string in the field — for a date, the native yyyy-MM-dd.
3 (number)"" (string)<!-- Through a formControl a number field's value is a number (null when empty). -->
<div>
<gog-inputfield label="Quantity" type="number" [min]="1" [max]="10" [formControl]="quantity" />
<code>{{ quantity.value }} ({{ typeOf(quantity.value) }})</code>
</div>
<!-- [(value)] always hands back the string. -->
<div>
<gog-inputfield label="Delivery date" type="date" [(value)]="delivery" />
<code>"{{ delivery() }}" ({{ typeOf(delivery()) }})</code>
</div>floatLabel rests the label inside the field like a placeholder and floats it on focus or once there is content. in stays inside the border, on centres on the top border, over floats fully above — each shown empty, then with a value. floatLabelShowPlaceholder brings the placeholder back under the floated label.
@for (variant of variants; track variant) {
<gog-inputfield
[floatLabel]="variant"
[label]="'floatLabel: ' + variant"
placeholder="e.g. Ada"
/>
<gog-inputfield [floatLabel]="variant" [label]="'floatLabel: ' + variant" value="Ada Lovelace" />
}
<!-- The placeholder shows under the floated label once it has somewhere to float to. -->
<gog-inputfield
floatLabel="over"
floatLabelShowPlaceholder
label="floatLabelShowPlaceholder"
placeholder="e.g. Ada"
/>errorDisplay="manual", the default, shows errorMessage for as long as it is non-empty — you own the timing. Type one or two characters.
<!-- errorDisplay="manual" (the default): the message shows while it is non-empty. -->
<gog-inputfield
label="Username"
[(value)]="username"
[errorMessage]="username().length > 0 && username().length < 3 ? 'At least 3 characters' : ''"
/> Wire it with [formControl] instead of [(value)]. With errorDisplay="auto" the error shows once the control is touched and invalid — leave the empty field to see it. Disabling the control disables the field.
value: "" · touched: false · disabled: false <div>
<gog-inputfield
label="Email (reactive form)"
placeholder="[email protected]"
[formControl]="control"
errorMessage="Enter a valid email"
errorDisplay="auto"
/>
<div>
<gog-button variant="outline" size="sm" (gogClick)="control.markAsTouched()">
markAsTouched()
</gog-button>
<gog-button variant="outline" size="sm" (gogClick)="toggleDisabled()">
{{ control.disabled ? 'enable()' : 'disable()' }}
</gog-button>
</div>
<code>
value: "{{ control.value }}" · touched: {{ control.touched }} · disabled: {{ control.disabled }}
</code>
</div> Fields fill their container by default — the dashed box here. [fullWidth]="false" shrinks the field to a text input's own width.
<gog-inputfield label="fullWidth (default)" placeholder="Fills the container" />
<gog-inputfield label='[fullWidth]="false"' [fullWidth]="false" placeholder="00000" />GOG_CONFIGcontrol.size, control.clearable and floatLabel.variant set the defaults for every field under the provider; an instance's own input still wins. In an app the provider goes in app.config.ts — see Global Configuration.
<gog-inputfield label="Size and float label from the config" placeholder="Placeholder" />
<gog-inputfield label='size="sm" — the instance wins' size="sm" placeholder="Placeholder" />
<!-- control.clearable: every field gets a clear button without asking. -->
<gog-inputfield label="Clearable from the config" value="42" />gog-inputfield renders a native <input> wired to its <label>, so the platform supplies the role, the keyboard and the name.
label. A field with no visible label of its own takes your <label for> through inputId; there is no ariaLabel input, so a nameless field cannot be shipped by accident. errorMessage sets aria-invalid="true" and links the message with aria-describedby. inputMode, autocomplete and spellcheck are forwarded to the native input. incrementLabel, decrementLabel, clearAriaLabel and the show/hide labels, or GOG_CONFIG.labels. A stepper button at its bound is disabled. | 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. |
| Name | Payload | Description |
|---|---|---|
valueChange | string | Emitted on every edit. Comes from the value model input. |
| Directive | Context | 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" and type="number" it renders beside the reveal toggle or the stepper, which keep the outer edge. The clear button, while it shows, outranks it. |
The field's own buttons carry data-gog-partincrement, decrement, clear and password-toggle — so a test or an automation script can find them with [data-gog-part="clear"]. Prefer it to the internal gog-input__* classes, which may change.
Set any of these once with provideGogConfig() instead of repeating them on every instance — an instance's own input still wins when it sets one itself. See Global Configuration for the full reference.
GOG_CONFIG.control.sizeGOG_CONFIG.control.errorDisplayGOG_CONFIG.control.clearableGOG_CONFIG.floatLabel.variantGOG_CONFIG.floatLabel.showPlaceholderGOG_CONFIG.inputfield.showSpinButtonsGOG_CONFIG.labels.clearGOG_CONFIG.labels.increment — type="number" spin buttonsGOG_CONFIG.labels.decrement — type="number" spin buttonsGOG_CONFIG.labels.showPasswordGOG_CONFIG.labels.hidePasswordEvery 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 / -label-font-family / -label-font-size / -label-font-weight / -label-letter-spacing / -label-line-height / -label-text-transform | Field label. Each aliases its --gog-field-label-* counterpart. |
--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. |