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)
idstringOverride id (else inherits from GkField)
namestringname attribute
typestring'text'Input type
autocompletestringAutocomplete hint
placeholderstringPlaceholder text
disabledbooleanfalseDisabled state
readonlybooleanfalseRead-only
ariaLabelstringUse when no visible label
autofocusbooleanfalseFocus the control on mount
prefixstringStatic text before the field
suffixstringStatic text after the field
counterboolean | number | stringShow a character count; true = count only; number or numeric string = max (shown as n / max)
counterValuenumber | (value: string) => numberOverride the displayed count
persistentCounterbooleanfalseWhen true, the counter is always shown; otherwise only while focused
rolestringPassed 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.