Package Exports
- sveltejs-forms
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sveltejs-forms) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sveltejs-forms
Declarative forms for Svelte.
Install
$ npm i sveltejs-forms
or
$ yarn add sveltejs-forms
How to use
Example
<script>
import { Form, Input } from 'sveltejs-forms';
import * as yup from 'yup';
function handleSubmit({ detail: { values, setSubmitting, resetForm } }) {
setTimeout(() => {
console.log(values);
setSubmitting(false);
resetForm();
}, 2000);
/**
* {
* email: 'email@example.com',
* password: '123456'
* }
*/
}
const schema = yup.object().shape({
email: yup
.string()
.required()
.email(),
password: yup.string().min(4)
});
</script>
<Form {schema} on:submit={handleSubmit} let:isSubmitting>
<Input name="email" />
<Input name="password" type="password" />
<button type="submit" disabled={isSubmitting}>Sign in</button>
</Form>