0.1.3 • Published 7 months ago

sharpcodes-react-form-components v0.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Installation:

shadcn-ui

$ npm install sharpcodes-react-form-components react-hook-form

Initialize shadcn-ui

$ npx shadcn-ui@latest init

Add shadcn-ui components

$ npx shadcn-ui@latest add form input -y

Basic usage:

import { FormInputField } from 'sharpcodes-react-form-components'
import { Form } from '@components/form'
import { useForm } from 'react-hook-form'

type FormValues = { username: string }

const MyComponent = () => {
	const form = useForm<FormValues>({
		defaultValues: { username: '' }
	})

	const onSubmit = (values: FormValues) => {}

	return (
		<Form {...form}>
			<form onSubmit={form.handleSubmit(onSubmit)}>
				<FormInputField field={{ control: form.control, name: 'username' }} />
			</form>
		</Form>
	)
}

export default MyComponent