solid-signal-form
v0.1.1
Published
Solid-js forms library with api similar to react-hook-form
Downloads
3
Maintainers
Readme
Install
npm i react-hook-form
yarn add react-hook-form
Quickstart
import { createForm } from 'solid-signal-form';
import { Show } from 'solid-js';
const App = () => {
const { register, handleSubmit, formState: { errors } } = createForm();
const submit = handleSubmit((values) => {
console.log(values)
})
return (
<form onSubmit={submit}>
<input {...register('login', { require: 'Last name is required.' })} /> {/* register an input */}
<Show when={errors.login}>
<p>{errors.login.message}</p>
</Show>
<input {...register('password', {
require: 'Please enter password.',
validation: (value) => value.length < 8 && 'Password must have at least 8 characters.',
})} />
<Show when={errors.password}>
<p>{errors.password.message}</p>
</Show>
<input type="submit" />
</form>
);
};
export default App;