zodkra
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Zodkra

An easier way to handle forms using Chakra UI and zod in a react environment.

FormControlInput

Using our carefuly crafted FormHook, you can just plugged in some inputs and the job's done. Check GitHub to keep in check with the project and it's ongoing documentation in progress.

import { z } from "zod";
const relevantInformationsSchema = z.object({
  name: z.string().min(1),
  email: z.string().email()
});

type MyFormComponentProps = {
  submitLabel?: string,
  onSubmit?: () => void
};

export default function MyFormComponent({ submitLabel, onSubmit }: MyFormComponentProps) {
  return (
    <FormHook
      fields={relevantInformationSchema}
      onSubmit={(data) => {
        // Stonk data, fully typed
        onSubmit && onSubmit();
      }}
    >
    {
      (register, errors, isSubmitting) => (
        {/* This is your starting form here. */}
        <FormControlInput
          required={true}
          id={"name"}
          w={96}
          label={"Your name"}
          placeholder={"Enter your name"}
          register={register}
          error={errors.name}
        />
        <FormControlInput
          required={true}
          id={"email"}
          w={96}
          label={"Your email"}
          placeholder={"Enter your email"}
          register={register}
          error={errors.email}
        />
      );
    }
    </FormHook>
  );
}

Package Sidebar

Install

npm i zodkra

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

11.3 kB

Total Files

9

Last publish

Collaborators

  • friquet-luca