Svelte Forms

A simple form component that doesn't care about what you put in it. It just works.
Alternatives To Svelte Forms
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
React Hook Form34,0991271,337a day ago951September 23, 20229mitTypeScript
📋 React Hooks for form state management and validation (Web + React Native)
Redux Form12,61411,7811,2434 days ago235November 17, 2021491mitJavaScript
A Higher Order Component using react-redux to keep form state in a Redux store
Eureka11,588
49014 days ago27September 15, 2020170mitSwift
Elegant iOS form builder in Swift
Vee Validate9,6342,1907355 days ago282September 19, 202248mitTypeScript
✅ Painless Vue forms
Formily9,33411911 days ago209September 20, 202211mitTypeScript
📱🚀 🧩 Cross Device & High Performance Normal Form/Dynamic(JSON Schema) Form/Form Builder -- Support React/React Native/Vue 2/Vue 3
Parsley.js9,045329416 months ago47December 10, 201969mitJavaScript
Validate your forms, frontend, without writing a single line of javascript
React Final Form7,217500384a month ago76April 01, 2022385mitJavaScript
🏁 High performance subscription-based form state management for React
Tcomb Form Native3,162499187 months ago53October 11, 2018128mitJavaScript
Forms library for react-native
Formkit2,633132 days ago144September 23, 202251mitTypeScript
Vue Forms ⚡️ Supercharged
Formsy React2,59922 years ago1November 27, 2015149mitJavaScript
A form input builder and validator for React JS
Alternatives To Svelte Forms
Select To Compare


Alternative Project Comparisons
Readme

A no-fuss Svelte form component that just works.

  • Plug'n'Play. Input elements in, values out.
  • Works just like a normal form. Except it does all the tedious work for you.
  • Extendable. Work with most inputs and custom input components out of the box.
  • Two-Way Binding. Svelte-forms is two-way bound by default. Change a value in your object, and it changes in your inputs.
  • A toolbox of actions to apply to your elements: Validate, FocusOnSelect, Numbers, TextareaAutoRezie, and many more. (Soon!)

Try it out on the Svelte REPL!

Usage

Simply bind to the components values property:

Using built-in HTML input elements:

<script>
  import Form from "@svelteschool/svelte-forms";
  let values;
</script>

<Form bind:values>
  <input
    placeholder="Enter first name..."
    type="text"
    name="firstName" />
  <input
    placeholder="Enter last name..."
    type="text"
    name="lastName" />
</Form>

Here's how the values object would be structured in the above case:

{
  firstName: 'Svelte',
  lastName: 'School'
}

Inputs that do not have a name property or are disabled will not show up in the object.

File inputs are not supported.

Props

prop name type default
actions [[action, actionProp]] []

actions

The actions prop takes an array of [action, options]. The action is applied to the form element using the options just like it would be if you manually applied it to an element: use:action={options}.

Validation

Handling form validation is pretty straight forward in Svelte using this library, you'd pick your preferred validation library (Yup for example) and just do a reactive statement like so: $: validity = validateForm(values) where validateForm is a function that does just that.

Installing

Simple. Install it using yarn or npm.

yarn add @svelteschool/svelte-forms

npm install @svelteschool/svelte-forms

If you're using Sapper, make sure to install it as a dev dependency:

yarn add -D @svelteschool/svelte-forms

Running the tests

Run tests by running the test script:

yarn test

Contribute

If you are interested in contributing you are welcome to open PRs. Please make sure all tests pass and if you add functionality, add your own tests.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Popular Form Projects
Popular Validation Projects
Popular User Interface Components Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Javascript
Validation
Form