Skip to content

GkInput ​

Single-line input bound with v-model. When placed inside GkField, it receives aria-invalid and aria-describedby from the field error region (and from the optional character counter when visible).

When to use ​

Use for email, password, search, and other native input types. Pair with GkField for labels and validation messages.

Live Examples ​

Basic

Minimal GkField + GkInput with v-model.

Best practice: Always wrap in GkField when you have a visible label so id and aria-describedby stay aligned.

Prefix & counter

Static prefix text and a character counter; persistent counter stays visible.

$
0 / 12

Best practice: Use v-model.trim on text-like types when you want blur-time trimming.

Readonly, suffix, and disabled search

Readonly input with suffix; disabled search with number + trim modifiers.

USD

Best practice: For standalone inputs, pass ariaLabel so the control has an accessible name.

API ​

Props ​

PropTypeDefaultDescription
modelValuestring | numberrequiredBound value (use v-model)
idstring—Override id (else inherits from GkField)
namestring—name attribute
typestring'text'Input type
autocompletestring—Autocomplete hint
placeholderstring—Placeholder text
disabledbooleanfalseDisabled state
readonlybooleanfalseRead-only
ariaLabelstring—Use when no visible label
autofocusbooleanfalseFocus the control on mount
prefixstring—Static text before the field
suffixstring—Static text after the field
counterboolean | number | string—Show a character count; true = count only; number or numeric string = max (shown as n / max)
counterValuenumber | (value: string) => number—Override the displayed count
persistentCounterbooleanfalseWhen true, the counter is always shown; otherwise only while focused
rolestring—Passed to the native <input>
size'xs' | 'sm' | 'md' | 'lg' | 'xl'—Visual control scale; omit to use GK_FORM_CONTROLS / global defaults (default md)

Root attributes (except class, which applies to the outer wrapper) are forwarded to the <input>.

Modifiers ​

Use Vue’s v-model modifiers on GkInput:

ModifierBehavior
.trimOn blur, the value is trimmed (for text, search, password, tel, url).
.numberCoerces to a number when possible (empty string stays empty).

Events ​

EventPayloadDescription
update:modelValuestring | numberEmitted on input
update:focusedbooleantrue on focus, false on blur

Slots ​

SlotPropsDescription
counter{ count, max }Replace the default counter text

Examples ​

Each scenario under Live Examples includes a copyable Vue snippet (source is imported from the same SFC as the preview).

Accessibility notes ​

  • Prefer wrapping GkInput with GkField for label and error semantics.
  • When used standalone, pass ariaLabel so the control has an accessible name.
  • Use persistentCounter for always-visible limits in forms with strict input quotas.

Released under the MIT License.