Skip to content

quasar-form

JSON Schema-driven form builder for Quasar

Overview

quasar-form generates Quasar forms automatically from a JSON Schema. Given a schema, KForm introspects each property, selects the appropriate field component, enforces validation rules, and exposes a simple API to fill, read and validate the form values.

It is organized around 3 modules:

  • componentsKForm and a library of 27 field types
  • composablesuseSchema and useField for reusable field logic
  • utilities — schema registry and field helpers

Components

KForm

KForm is the main component. It takes a JSON Schema as input and renders all declared properties as the appropriate field components:

vue
<KForm :schema="userSchema" ref="form" />
js
const userSchema = {
  $id: 'user',
  type: 'object',
  properties: {
    name: { type: 'string', field: { component: 'KTextField' } },
    age:  { type: 'integer', minimum: 0 }
  },
  required: ['name']
}

The field.component property in each schema property selects which field component to render. When omitted, quasar-form picks a default based on the JSON Schema type:

JSON Schema typeDefault component
stringKTextField
integer / numberKNumberField
booleanKToggleField

KForm exposes the following methods:

MethodDescription
fill(values)Distributes values to matching fields
values()Returns the current field values as an object
validate()Validates the form against the schema and returns { isValid, errors }
apply(object)Writes the current values into a target object
clear()Resets all fields

Field components

The following field components are available:

ComponentDescription
KTextFieldSingle-line text input
KTextareaFieldMulti-line text input
KNumberFieldNumeric input with optional unit
KPasswordFieldPassword input with visibility toggle
KEmailFieldEmail address input
KPhoneFieldPhone number input
KUrlFieldURL input
KDateFieldDate picker
KDatetimeFieldDate and time picker
KDateTimeRangeFieldDate and time range picker
KColorFieldColor picker
KColorScaleFieldColor scale picker
KToggleFieldBoolean toggle
KSliderFieldNumeric slider
KSelectFieldSingle-value select
KOptionsFieldMulti-value option selector
KIconFieldIcon picker
KFileFieldFile upload
KChipsFieldFree-form chip list
KTagFieldTag selector
KTokenFieldToken input
KItemFieldItem selector backed by a service
KPropertyItemFieldKey/value property editor
KRoleFieldRole selector
KResolutionFieldResolution selector
KUnitFieldValue with unit selector

All field components are automatically registered into the @kalisio/quasar-core registry when the package is imported.

Composables

ComposableDescription
useSchema()Compiles a JSON Schema with AJV and returns a validate function and a reactive schema ref
useField()Provides common field behaviour: value binding, validation state, label and tooltip resolution

Utilities

ExportDescription
schemaRegistryAJV-based registry for compiling and caching JSON Schema validators
fieldPropsShared prop definitions reused across all field components
makeDiacriticPattern(str, options?)Builds a regex pattern that matches a string regardless of diacritics
getIconName(icon, field?)Resolves an icon descriptor to a string icon name

Installation

Install with your preferred package manager:

bash
pnpm add @kalisio/quasar-form
bash
npm install @kalisio/quasar-form
bash
yarn add @kalisio/quasar-form