An open API service indexing awesome lists of open source software.

https://github.com/x0k/svelte-jsonschema-form

Svelte 5 library for creating forms based on JSON schema.
https://github.com/x0k/svelte-jsonschema-form

forms json-schema svelte svelte5

Last synced: 24 days ago
JSON representation

Svelte 5 library for creating forms based on JSON schema.

Awesome Lists containing this project

README

        

# svelte-jsonschema-form

Svelte 5 library for creating forms based on JSON schema.
Unofficial port of [react-jsonschema-form](https://github.com/rjsf-team/react-jsonschema-form).

- [Documentation](https://x0k.github.io/svelte-jsonschema-form/v2/)
- [Playground](https://x0k.github.io/svelte-jsonschema-form/playground2/)

## Installation

Install the library, basic theme and `ajv` for validation.

```shell
npm install @sjsf/form@next @sjsf/basic-theme@next @sjsf/ajv8-validator@next ajv@8
```

## Usage

```svelte

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
})

```

## License

This project includes modifications of code from [react-jsonschema-form](https://github.com/rjsf-team/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](LICENSE) and [LICENSE-APACHE](packages/form/LICENSE-APACHE) for details.

## See also

- [Other JSON Schema to Web UI tools](https://json-schema.org/tools?query=&sortBy=name&sortOrder=ascending&groupBy=toolingTypes&licenses=&languages=&drafts=&toolingTypes=schema-to-web-UI)
- [Converting JSON to table](https://github.com/x0k/json-to-table)
- [Simple build automation tool - mk](https://github.com/x0k/mk)