@jsonforms/vue package provides Vue 3 components for integrating JSON Forms into Vue applications. These components use Vue’s Composition API and provide/inject pattern for state management.
JsonForms
The main component for rendering a complete JSON Form. This is the root component that provides form state to all child components.Props
The data to be rendered by the form. Can be any JSON-compatible type (object, array, string, number, boolean).
The JSON Schema describing the data structure and validation rules. If not provided, a schema will be generated from the data.
The UI Schema defining how the form should be rendered. If not provided, a default UI schema will be generated from the JSON Schema.
Array of renderer registrations that define which components handle which UI schema elements. This is required.
Array of cell renderer registrations for rendering controls in compact mode (e.g., within tables).
Global configuration object that can be accessed by all renderers.
When true, all form controls will be rendered in read-only mode.
Array of UI schema registrations for dynamic schema resolution.
Controls when validation errors are displayed. Options:
'ValidateAndShow': Validate and show errors'ValidateAndHide': Validate but don’t show errors'NoValidation': Don’t validate
Custom AJV instance for validation. If not provided, a default instance will be created.
Internationalization configuration including locale, translate function, and error translation.
Additional validation errors to display alongside schema validation errors.
Custom middleware function for intercepting and modifying core state updates.
Events
Emitted when the form data or validation errors change.Event structure:
Example
DispatchRenderer
Internal component that dispatches rendering to the appropriate registered renderer based on the UI schema element. This component selects the best matching renderer using tester functions.Props
Accepts all renderer props viarendererProps():
The JSON Schema for the current element.
The UI Schema element to render.
The data path to the current element.
Whether the element is enabled.
Optional override for the renderer registry.
Optional override for the cell registry.
Optional override for the configuration.
Usage
DispatchCell
Internal component for dispatching cell rendering. Similar to DispatchRenderer but specifically for cells, which are compact control renderers typically used in tables.Props
Accepts the same props asDispatchRenderer but with ControlElement type for uischema:
The control UI Schema element to render as a cell.
Usage
UnknownRenderer
Fallback component displayed when no suitable renderer is found for a UI schema element.Template
Creating Custom Renderers
To create custom renderers for Vue, you can use the composables provided by the package. Here’s an example:Provide/Inject Pattern
TheJsonForms component provides the following values to all descendant components:
jsonforms: The complete JSON Forms state (JsonFormsSubStates)dispatch: Function to dispatch core actions
All custom renderers must be used within a
JsonForms component to have access to the form state via Vue’s provide/inject.