Svelte 5 library for creating forms based on JSON schema. Unofficial port of react-jsonschema-form.
Install the library, basic theme and ajv
for validation.
npm install @sjsf/form@next @sjsf/basic-theme@next @sjsf/ajv8-validator@next ajv@8
<script lang="ts">
import { createForm, BasicForm, type Schema } from '@sjsf/form';
import { resolver } from '@sjsf/form/resolvers/basic';
import { translation } from '@sjsf/form/translations/en';
import { theme } from '@sjsf/basic-theme';
import { createFormValidator } from "@sjsf/ajv8-validator";
const validator = createFormValidator();
const schema: Schema = {
title: 'Tasks',
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string',
title: 'Name',
},
description: {
type: 'string',
title: 'Description',
},
},
required: ["name"]
},
}
const form = createForm({
theme,
schema,
resolver
validator,
translation,
onSubmit: console.log
})
</script>
<BasicForm {form} />
This project includes modifications of code from react-jsonschema-form, which is licensed under the Apache License, Version 2.0. The rest of the project is under the MIT license.
See LICENSE-MIT and LICENSE-APACHE for details.