Skip to content

Vue

Terminal window
npm i @golemui/core @golemui/gui-shared @golemui/vue @golemui/gui-vue --save

GolemUI’s default widgets are Lit custom elements (<gui-textinput>, <gui-button>, …). Tell the Vue template compiler to leave the gui-* tags alone so they reach the DOM as native custom elements:

vite.config.ts
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('gui-'),
},
},
}),
],
});

Import the core styles in your application entry point or global stylesheet:

@import '@golemui/gui-components/index.css';

<GuiForm> only needs a formDef. The framework’s built-in widget set is loaded automatically, and an empty form renders fine without initial data.

<script setup lang="ts">
import { gui } from '@golemui/gui-shared';
import { GuiForm } from '@golemui/gui-vue';
const config = {
formDef: [gui.inputs.textInput('username', { label: 'Username' })],
};
</script>
<template>
<GuiForm :config="config" />
</template>
<script setup lang="ts">
import { GuiForm } from '@golemui/gui-vue';
import formDef from './my-form.json';
const config = { formDef };
</script>
<template>
<GuiForm :config="config" />
</template>

Reach for these only when you need them. data prefills the form; customWidgetLoaders is for widgets you’ve built yourself (the framework’s built-ins are merged automatically). Every other config property in the table below follows the same rule — opt in as the form grows.

<script setup lang="ts">
import { gui } from '@golemui/gui-shared';
import { GuiForm } from '@golemui/gui-vue';
import { myCustomWidgets } from './my-custom-widgets';
const config = {
formDef: [gui.inputs.textInput('username', { label: 'Username' })],
data: { username: 'octocat' }, // optional — initial form data
customWidgetLoaders: myCustomWidgets, // optional — only when the form references widgets you've built yourself
};
</script>
<template>
<GuiForm :config="config" />
</template>
<script setup lang="ts">
import { GuiForm } from '@golemui/gui-vue';
import { myCustomWidgets } from './my-custom-widgets';
import formDef from './my-form.json';
const config = {
formDef,
data: { username: 'octocat' }, // optional — initial form data
customWidgetLoaders: myCustomWidgets, // optional — only when the form references widgets you've built yourself
};
</script>
<template>
<GuiForm :config="config" />
</template>

All initialization properties are bundled in the required config prop (GuiFormInitConfig):

config propertyTypeDescription
formDef (required)FormInputProgrammatic gui.* array or parsed JSON form definition.
formSelectorsGslSelectorsInputGSL selector decorators. Programmatic-only.
formConfigDxFormConfigDX engine wiring (loaders, item renderers, dependencies, validateOn, …). Programmatic-only.
dataRecord<string, any>Initial form data.
metaRecord<string, any>Out-of-band metadata you want to thread through events and state.
customWidgetLoadersWidgetLoaders<Component<WithWidget>>Custom widget map; merged with the default Vue widget set.
itemRenderersRecord<string, VueItemRenderer<any>>Custom item-renderer map (for dropdown, list, etc.).
customValidatorsCustomValidatorSchemasCustom validator schemas referenced by validator: { type: 'custom', ... }.
middlewaresMiddleware<State, Action>[]Store middlewares (logging, persistence, devtools).
validateOnValidateOnWhen validation runs: 'eager' (default), 'change', 'blur', 'submit', or an array.
dependenciesDependenciesExternal helpers (e.g. a markdown parser).
localizationI18nTranslatorTranslator implementing the I18nTranslator interface.
formNamestringOptional form identifier (useful when you have several forms on a page).

Direct props (outside config):

PropTypeDescription
autocompletestringSets the underlying <form> element’s autocomplete attribute.

The component also emits two events:

EventPayload typeDescription
@form-eventFormEventFired when a widget fires a wired event.
@form-healthFormHealthFired when the form’s validation status changes.

See Configuration for details on each prop, plus the Programmatic-only vs JSON-form notes.

Build your own widgets as Vue SFCs that consume the framework adapter via the useInputWidget, useLayoutWidget, useDisplayWidget, and useActionWidget composables exported from @golemui/vue. The composables expose Ref-typed reactive state (value, errors, isTouched, templateData) and disposal-safe dispatchers; they handle observable cleanup via onScopeDispose automatically. See Extending GolemUI / Widgets for the full walkthrough.