Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
import { useForm, validators, Hint, minLength } from "svelte-use-form@2.0.0";
const form = useForm();
// We could also define the valdidator here
// const form = useForm({
// minimalExample: { validators: [minLength(5)] }
// })
</script>

<form use:form>
<input name="minimalExample" use:validators={[minLength(5)]} />
<Hint for="minimalExample" on="minLength" let:value>
The title requires at least {value} characters.
</Hint>

<button disabled={!$form.valid}>Submit</button> <br />
</form>
<pre>
{JSON.stringify($form, null, " ")}
</pre>

<style>
:global(.touched:invalid) {
border-color: red;
outline-color: red;
}
</style>
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */