SVAR
Installation
Section titled “Installation”npm i @sjsf-lab/svar-themepnpm add @sjsf-lab/svar-themeyarn add @sjsf-lab/svar-themebun add @sjsf-lab/svar-themedeno add @sjsf-lab/svar-themeRequired peer dependencies: @sjsf/form@3.5.0 @svar-ui/svelte-core@2.3.0 svelte@5.34.8
Configuration
Section titled “Configuration”Import and wrap your app with the Willow component:
<script lang="ts"> import { Willow } from "@svar-ui/svelte-core";</script>
<Willow> <!-- your app --></Willow>Extra widgets
Section titled “Extra widgets”You can connect extra widgets using the following include imports:
// Used by default in the following fields: multiEnumFieldimport "@sjsf-lab/svar-theme/extra-widgets/checkboxes-include"import "@sjsf-lab/svar-theme/extra-widgets/color-picker-include"import "@sjsf-lab/svar-theme/extra-widgets/color-select-include"import "@sjsf-lab/svar-theme/extra-widgets/combobox-include"import "@sjsf-lab/svar-theme/extra-widgets/date-picker-include"import "@sjsf-lab/svar-theme/extra-widgets/date-range-picker-include"import "@sjsf-lab/svar-theme/extra-widgets/multi-select-include"import "@sjsf-lab/svar-theme/extra-widgets/radio-buttons-include"import "@sjsf-lab/svar-theme/extra-widgets/radio-include"import "@sjsf-lab/svar-theme/extra-widgets/range-include"import "@sjsf-lab/svar-theme/extra-widgets/switch-include"import "@sjsf-lab/svar-theme/extra-widgets/textarea-include"Widgets demo
Section titled “Widgets demo”{ "type": "object", "properties": { "checkbox": { "type": "object", "properties": { "default": { "type": "boolean" }, "error": { "type": "boolean" } }, "required": [ "default" ] }, "checkboxes": { "type": "object", "properties": { "default": { "type": "array", "items": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "uniqueItems": true }, "error": { "type": "array", "items": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "uniqueItems": true } }, "required": [ "default" ] }, "number": { "type": "object", "properties": { "default": { "type": "number" }, "error": { "type": "number" } }, "required": [ "default" ] }, "select": { "type": "object", "properties": { "default": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "error": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] } }, "required": [ "default" ] }, "text": { "type": "object", "properties": { "default": { "type": "string" }, "error": { "type": "string" } }, "required": [ "default" ] }, "colorPicker": { "type": "object", "properties": { "default": { "type": "string" }, "error": { "type": "string" } }, "required": [ "default" ] }, "colorSelect": { "type": "object", "properties": { "default": { "type": "string" }, "error": { "type": "string" } }, "required": [ "default" ] }, "combobox": { "type": "object", "properties": { "default": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "error": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] } }, "required": [ "default" ] }, "datePicker": { "type": "object", "properties": { "default": { "type": "string" }, "error": { "type": "string" } }, "required": [ "default" ] }, "dateRangePicker": { "type": "object", "properties": { "default": { "type": "object", "properties": { "start": { "type": "string" }, "end": { "type": "string" } } }, "error": { "type": "object", "properties": { "start": { "type": "string" }, "end": { "type": "string" } } } }, "required": [ "default" ] }, "multiSelect": { "type": "object", "properties": { "default": { "type": "array", "items": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "uniqueItems": true }, "error": { "type": "array", "items": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "uniqueItems": true } }, "required": [ "default" ] }, "radioButtons": { "type": "object", "properties": { "default": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "error": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] } }, "required": [ "default" ] }, "radio": { "type": "object", "properties": { "default": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] }, "error": { "type": "string", "enum": [ "foo", "bar", "fuzz", "qux" ] } }, "required": [ "default" ] }, "range": { "type": "object", "properties": { "default": { "type": "number" }, "error": { "type": "number" } }, "required": [ "default" ] }, "switch": { "type": "object", "properties": { "default": { "type": "boolean" }, "error": { "type": "boolean" } }, "required": [ "default" ] }, "textarea": { "type": "object", "properties": { "default": { "type": "string" }, "error": { "type": "string" } }, "required": [ "default" ] } }}{ "checkbox": { "default": { "ui:options": { "title": "checkbox" } }, "error": { "ui:options": { "title": "checkbox" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "checkboxes": { "default": { "ui:components": { "arrayField": "multiEnumField" }, "ui:options": { "title": "checkboxes" } }, "error": { "ui:components": { "arrayField": "multiEnumField" }, "ui:options": { "title": "checkboxes" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "number": { "default": { "ui:options": { "title": "number" } }, "error": { "ui:options": { "title": "number" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "select": { "default": { "ui:components": { "stringField": "enumField" }, "ui:options": { "title": "select" } }, "error": { "ui:components": { "stringField": "enumField" }, "ui:options": { "title": "select" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "text": { "default": { "ui:options": { "title": "text" } }, "error": { "ui:options": { "title": "text" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "colorPicker": { "default": { "ui:components": { "textWidget": "svarColorPickerWidget" }, "ui:options": { "title": "colorPicker" } }, "error": { "ui:components": { "textWidget": "svarColorPickerWidget" }, "ui:options": { "title": "colorPicker" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "colorSelect": { "default": { "ui:components": { "textWidget": "svarColorSelectWidget" }, "ui:options": { "title": "colorSelect" } }, "error": { "ui:components": { "textWidget": "svarColorSelectWidget" }, "ui:options": { "title": "colorSelect" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "combobox": { "default": { "ui:components": { "stringField": "enumField", "selectWidget": "comboboxWidget" }, "ui:options": { "title": "combobox" } }, "error": { "ui:components": { "stringField": "enumField", "selectWidget": "comboboxWidget" }, "ui:options": { "title": "combobox" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "datePicker": { "default": { "ui:components": { "textWidget": "datePickerWidget" }, "ui:options": { "title": "datePicker" } }, "error": { "ui:components": { "textWidget": "datePickerWidget" }, "ui:options": { "title": "datePicker" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "dateRangePicker": { "default": { "ui:components": { "objectField": "aggregatedField", "aggregatedWidget": "dateRangePickerWidget" }, "ui:options": { "title": "dateRangePicker" } }, "error": { "ui:components": { "objectField": "aggregatedField", "aggregatedWidget": "dateRangePickerWidget" }, "ui:options": { "title": "dateRangePicker" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "multiSelect": { "default": { "ui:components": { "arrayField": "multiEnumField", "checkboxesWidget": "multiSelectWidget" }, "ui:options": { "useLabel": true, "title": "multiSelect" } }, "error": { "ui:components": { "arrayField": "multiEnumField", "checkboxesWidget": "multiSelectWidget" }, "ui:options": { "useLabel": true, "title": "multiSelect" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "radioButtons": { "default": { "ui:components": { "stringField": "enumField", "selectWidget": "radioButtonsWidget" }, "ui:options": { "useLabel": false, "title": "radioButtons" } }, "error": { "ui:components": { "stringField": "enumField", "selectWidget": "radioButtonsWidget" }, "ui:options": { "useLabel": false, "title": "radioButtons" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "radio": { "default": { "ui:components": { "stringField": "enumField", "selectWidget": "radioWidget" }, "ui:options": { "useLabel": false, "title": "radio" } }, "error": { "ui:components": { "stringField": "enumField", "selectWidget": "radioWidget" }, "ui:options": { "useLabel": false, "title": "radio" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "range": { "default": { "ui:components": { "numberWidget": "rangeWidget" }, "ui:options": { "title": "range" } }, "error": { "ui:components": { "numberWidget": "rangeWidget" }, "ui:options": { "title": "range" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "switch": { "default": { "ui:components": { "checkboxWidget": "switchWidget" }, "ui:options": { "title": "switch" } }, "error": { "ui:components": { "checkboxWidget": "switchWidget" }, "ui:options": { "title": "switch" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }, "textarea": { "default": { "ui:components": { "textWidget": "textareaWidget" }, "ui:options": { "title": "textarea" } }, "error": { "ui:components": { "textWidget": "textareaWidget" }, "ui:options": { "title": "textarea" } }, "ui:options": { "layouts": { "object-properties": { "style": "display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;" } } } }}Supported validation events
Section titled “Supported validation events”| checkbox | oninput, onchange |
| checkboxes | |
| number | oninput, onchange |
| select | oninput, onchange |
| text | oninput, onchange |
| colorPicker | |
| colorSelect | |
| combobox | |
| datePicker | onchange |
| dateRangePicker | onchange |
| multiSelect | oninput, onchange |
| radioButtons | |
| radio | oninput, onchange |
| range | oninput, onchange |
| switch | |
| textarea | oninput, onchange |
UI options
Section titled “UI options”import type { ButtonType } from "@sjsf/form/fields/components";import { Button as SvarButton, Checkbox as SvarCheckbox, CheckboxGroup as SvarCheckboxGroup, ColorPicker as SvarColorPicker, ColorSelect as SvarColorSelect, Combo, DatePicker as SvarDatePicker, DateRangePicker as SvarDateRangePicker, MultiCombo as SvarMultiCombo, RadioButtonGroup as SvarRadioButtonGroup, Segmented, Select as SvarSelect, Slider as SvarSlider, Switch as SvarSwitch, TextArea as SvarTextArea, Text as SvarText,} from "@svar-ui/svelte-core";import type { ComponentProps as SvelteComponentProps } from "svelte";
export interface UiOptions { /** * Overrides the props of the text input widget. */ svarText?: SvelteComponentProps<typeof SvarText>; /** * Overrides the props of the number input widget. */ svarNumber?: SvelteComponentProps<typeof SvarText>; /** * Overrides the props of the select widget. */ savrSelect?: SvelteComponentProps<typeof SvarSelect>; /** * Overrides the props of the checkbox widget. */ svarCheckbox?: SvelteComponentProps<typeof SvarCheckbox>; /** * Overrides the props of the checkboxes widget. */ svarCheckboxes?: SvelteComponentProps<typeof SvarCheckboxGroup>; /** * Overrides the props of the color picker widget. */ svarColorPicker?: SvelteComponentProps<typeof SvarColorPicker>; /** * Overrides the props of the color select widget. */ svarColorSelect?: SvelteComponentProps<typeof SvarColorSelect>; /** * Overrides the props of the combobox widget. */ svarCombobox?: SvelteComponentProps<typeof Combo>; /** * Overrides the props of the date picker widget. */ svarDatePicker?: SvelteComponentProps<typeof SvarDatePicker>; /** * Overrides the props of the date range picker widget. */ svarDateRangePicker?: SvelteComponentProps<typeof SvarDateRangePicker>; /** * Overrides the props of the multi-select widget. */ svarMultiSelect?: SvelteComponentProps<typeof SvarMultiCombo>; /** * Overrides the props of the radio buttons (segmented) widget. */ svarRadioButtons?: SvelteComponentProps<typeof Segmented>; /** * Overrides the props of the radio widget. */ svarRadio?: SvelteComponentProps<typeof SvarRadioButtonGroup>; /** * Overrides the props of the range (slider) widget. */ svarRange?: SvelteComponentProps<typeof SvarSlider>; /** * Overrides the props of the switch widget. */ svarSwitch?: SvelteComponentProps<typeof SvarSwitch>; /** * Overrides the props of the textarea widget. */ svarTextarea?: SvelteComponentProps<typeof SvarTextArea>; /** * Overrides the props of the button component. */ svarButton?: SvelteComponentProps<typeof SvarButton>; /** * Overrides the props of a button with a specific type. */ svarButtons?: { [B in ButtonType]: SvelteComponentProps<typeof SvarButton>; }; /** * Overrides the props of the submit button component. */ svarSubmitButton?: SvelteComponentProps<typeof SvarButton>;}