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 demo

Basic

Advanced

$
0 / 12

Edge case

USD

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>

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

Basic

vue
<script setup lang="ts">
import { GkField, GkInput } from 'god-kit/vue'
import { ref } from 'vue'

const value = ref('')
</script>

<template>
  <GkField label="Name">
    <GkInput v-model="value" autocomplete="name" />
  </GkField>
</template>

Prefix, counter, trim

vue
<GkField label="Amount">
  <GkInput v-model.trim="amount" prefix="$" :counter="80" placeholder="0.00" />
</GkField>

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.