JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1315
  • Score
    100M100P100Q108624F
  • License MIT

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

npm npm bundle size npm

GitHub Actions Status Maintainability

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>