1.0.0 • Published 2 years ago

@svelio/svelte-simple-forms v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Svelte simple forms

Simple forms for svelte! Heavily inspired by mantine-forms.

Status: Experimental

You are welcome to test the library, and support it by reporting bugs and suggesting features.

But please be aware that the API is not stable yet, and it may change in the future.

Do not expect a stable release before version 2.0.0.

Installation

npm

npm install --save-dev @svelio/svelte-simple-forms

yarn

yarn add -D @svelio/svelte-simple-forms

Usage

Basic usage

<script>
	import { createForm } from '@svelio/svelte-simple-forms';

	const { getInput, getForm, values } = createForm({
		initialValues: {
			name: '',
			email: ''
		}
	});
</script>

<form use:form={$values}>
	<input use:getInput={'name'} />
	<input use:getInput={'email'} />

	<button type="submit">Submit</button>
</form>

<p>Name: {$values.name}</p>
<p>Email: {$values.email}</p>

Form validation

<script>
	import { createForm } from '@svelio/svelte-simple-forms';

	const { getInput, getForm, values, errors } = createForm({
		initialValues: {
			name: '',
			email: ''
		},
		validate: {
			name: (value) => !value && 'Name is required',
			email: (value) => !value && 'Email is required'
		}
	});
</script>

<form use:form={$values}>
	<input use:getInput={'name'} />
	{#if $errors.name}
		<p>{$errors.name}</p>
	{/if}

	<input use:getInput={'email'} />
	{#if $errors.email}
		<p>{$errors.email}</p>
	{/if}

	<button type="submit">Submit</button>

	<p>Name: {$values.name}</p>
	<p>Email: {$values.email}</p>
</form>

Roadmap

  • Basic form functionality
  • Form validation
  • Support for custom input components (multi select, date picker, etc)
  • Form validation with yup
  • Form validation with zod
  • Form parsing (e.g. parse string to number)
1.1.0-beta.1

2 years ago

1.0.0

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago