Skip to content
Playground Form Builder
You’re viewing the documentation for v3. Looking for v2? Find it here.

svelte-jsonschema-form

Svelte 5 library for creating forms based on JSON schema.

Choose your favorite theme:

Terminal window
npm i @sjsf/form@next @sjsf/ajv8-validator@next ajv@8 @sjsf/basic-theme@next

Usage

<script lang="ts">
import { createForm, BasicForm } from "@sjsf/form";
import {
schema,
uiSchema,
initialValue,
type Data,
withFile,
} from "../data";
import * as defaults from "./defaults";
const form = createForm({
...defaults,
// required due to several forms on the page
idPrefix: "basic",
initialValue,
schema,
uiSchema,
onSubmit: ({ name }: Data) => window.alert(`Hello, ${name}`),
});
</script>
<BasicForm {form} />
<pre>{JSON.stringify(form.value, withFile, 2)}</pre>

This theme is not affiliated with, endorsed by, or sponsored by "daisyUI" brand.

Terminal window
npm i @sjsf/form@next @sjsf/ajv8-validator@next ajv@8 @sjsf/daisyui5-theme@next

Usage

<script lang="ts">
import { BasicForm, createForm } from "@sjsf/form";
import { createAstro } from "@/astro.svelte";
import {
schema,
uiSchema,
initialValue,
withFile,
type Data,
} from "../data";
import * as defaults from "./defaults";
const form = createForm({
...defaults,
// required due to several forms on the page
idPrefix: "daisyui5",
initialValue,
schema,
uiSchema,
onSubmit: ({ name }: Data) => window.alert(`Hello, ${name}`),
});
const astro = createAstro();
</script>
<BasicForm
{form}
style="background-color: transparent; margin-bottom: 1rem;"
data-theme={astro.darkOrLight}
/>
<pre>{JSON.stringify(form.value, withFile, 2)}</pre>

This theme is not affiliated with, endorsed by, or sponsored by "Flowbite" brand.

Terminal window
npm i @sjsf/form@next @sjsf/ajv8-validator@next ajv@8 @sjsf/flowbite3-theme@next

Usage

<script lang="ts">
import { BasicForm, createForm } from "@sjsf/form";
import { createAstro } from "@/astro.svelte";
import {
schema,
uiSchema,
initialValue,
type Data,
withFile,
} from "../data";
import * as defaults from "./defaults";
const form = createForm({
...defaults,
// required due to several forms on the page
idPrefix: "flowbite3",
initialValue,
schema,
uiSchema,
onSubmit: ({ name }: Data) => window.alert(`Hello, ${name}`),
});
const astro = createAstro();
</script>
<BasicForm {form} class="flex flex-col gap-4 mb-4 {astro.darkOrLight}" />
<pre>{JSON.stringify(form.value, withFile, 2)}</pre>

This theme is not affiliated with, endorsed by, or sponsored by "Skeleton" brand.

Terminal window
npm i @sjsf/form@next @sjsf/ajv8-validator@next ajv@8 @sjsf/skeleton3-theme@next

Usage

<script lang="ts">
import { BasicForm, createForm } from "@sjsf/form";
import { createAstro } from "@/astro.svelte";
import {
schema,
uiSchema,
initialValue,
type Data,
withFile,
} from "../data";
import * as defaults from "./defaults";
const form = createForm({
...defaults,
// required due to several forms on the page
idPrefix: "skeleton3",
initialValue,
schema,
uiSchema,
onSubmit: ({ name }: Data) => window.alert(`Hello, ${name}`),
});
const astro = createAstro();
</script>
<BasicForm
{form}
class="flex flex-col gap-4 {astro.darkOrLight}"
style="margin-bottom: 1rem;"
data-theme="cerberus"
/>
<pre>{JSON.stringify(form.value, withFile, 2)}</pre>

This theme is not affiliated with, endorsed by, or sponsored by "shadcn-svelte" brand.

Terminal window
npm i @sjsf/form@next @sjsf/ajv8-validator@next ajv@8 @sjsf/shadcn4-theme@next

Usage

<script lang="ts">
import { BasicForm, createForm } from "@sjsf/form";
import { setThemeContext } from "@sjsf/shadcn4-theme";
import * as components from "@sjsf/shadcn4-theme/new-york";
import { createAstro } from "@/astro.svelte";
import {
schema,
uiSchema,
initialValue,
type Data,
withFile,
} from "../data";
import * as defaults from "./defaults";
const form = createForm({
...defaults,
// required due to several forms on the page
idPrefix: "shadcn4",
initialValue,
schema,
uiSchema,
onSubmit: ({ name }: Data) => window.alert(`Hello, ${name}`),
});
const astro = createAstro();
setThemeContext({ components });
</script>
<BasicForm {form} class="flex flex-col gap-4 {astro.darkOrLight}" />
<pre style="padding-top: 1rem;">{JSON.stringify(form.value, withFile, 2)}</pre>

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.