npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@labmgm/forms

v0.1.4

Published

Form primitives for MGM Laboratory — Input, Textarea, Select, Combobox, Switch, Slider, FileDropzone, Wizard, plus React Hook Form + Zod helpers.

Readme

@labmgm/forms

The full forms toolkit for MGM Laboratory.

npm version

Field primitives, React Hook Form + Zod wiring, a polished <Field> wrapper, and a <Wizard> for multi-step flows.

pnpm add @labmgm/forms react-hook-form zod

@labmgm/forms supports Zod 3.25+ and Zod 4. It uses the Zod and React Hook Form instances already installed by your application, avoiding duplicate validation runtimes.

Storybook (Forms / Primitives) · Source


Quick example — validated signup form

import { Form, FormProvider, useMgmForm, Field, Input } from '@labmgm/forms';
import { emailSchema, passwordSchema, z } from '@labmgm/forms/schemas';
import { Button } from '@labmgm/react';
import { toast } from '@labmgm/toast';

const schema = z.object({
  email: emailSchema,
  password: passwordSchema,
});

export function SignupForm() {
  const form = useMgmForm(schema, { defaultValues: { email: '', password: '' } });
  return (
    <FormProvider {...form}>
      <Form
        onSubmit={form.handleSubmit(({ email }) => toast.success(`Welcome, ${email}`))}
        className="max-w-md space-y-4"
      >
        <Field label="Email" required error={form.formState.errors.email?.message}>
          <Input type="email" placeholder="[email protected]" {...form.register('email')} />
        </Field>
        <Field
          label="Password"
          required
          help="≥8 chars, with upper/lower/number."
          error={form.formState.errors.password?.message}
        >
          <Input type="password" {...form.register('password')} />
        </Field>
        <Button type="submit" fullWidth>
          Create account
        </Button>
      </Form>
    </FormProvider>
  );
}

Primitive components

| Component | Purpose | | ---------------------------- | --------------------------------------------------------------------------- | | Label | <label> with optional required asterisk | | Field | Wraps Label + input + help/error, wires aria-invalid / aria-describedby | | FieldError · FieldHelp | Sub-components for custom layouts | | Input | Text/email/url input with optional leading / trailing slots | | Textarea | Multi-line input | | SearchInput | Pre-wired with search icon + clear button | | NumberInput | Spinner with min/max/step, optional controls={false} | | PinInput | One-time-code input (default 6 digits) | | Checkbox · CheckboxGroup | Radix-backed, label + description slots | | Radio · RadioGroup | Radix-backed | | Switch | Radix-backed toggle | | Slider | Radix-backed range | | Select | Native-feeling Radix Select | | Combobox | Filterable single-select (cmdk) | | MultiSelect | Filterable multi-select with chip display | | TagInput | Free-form tag entry — Enter/comma to add | | FileDropzone | Drag-and-drop file picker with accept / maxSize | | ColorPicker | Brand presets + native color picker fallback |


useMgmForm() — React Hook Form + Zod

A thin wrapper around useForm() that wires the zodResolver for you:

import { useMgmForm } from '@labmgm/forms';
import { z } from '@labmgm/forms/schemas';

const schema = z.object({ name: z.string().min(2) });
const form = useMgmForm(schema, { defaultValues: { name: '' } });
//    ^? UseFormReturn<{ name: string }>

The returned object has the full React Hook Form API. Validation is automatic.


Multi-step <Wizard> + <StepRail>

import { Wizard, WizardStep, StepRail, useWizard } from '@labmgm/forms';
import { Button } from '@labmgm/react';

<Wizard defaultCurrent={0}>
  <WizardStep>
    <Step title="Basics" />
  </WizardStep>
  <WizardStep>
    <Step title="Files" />
  </WizardStep>
  <WizardStep>
    <Step title="Review" />
  </WizardStep>
</Wizard>;

function Step({ title }) {
  const w = useWizard();
  return (
    <div className="grid grid-cols-1 gap-6 sm:grid-cols-[200px_1fr]">
      <StepRail
        navigable
        steps={[
          { title: 'Basics', description: 'Name and category' },
          { title: 'Files', description: 'Upload assets' },
          { title: 'Review', description: 'Confirm details' },
        ]}
      />
      <div>
        <h2 className="text-h2">{title}</h2>
        <div className="mt-6 flex justify-between">
          <Button variant="ghost" onClick={w.prev} disabled={w.isFirst}>
            Back
          </Button>
          <Button onClick={w.next} disabled={w.isLast}>
            {w.isLast ? 'Finish' : 'Next'}
          </Button>
        </div>
      </div>
    </div>
  );
}

useWizard() exposes { current, count, next, prev, goTo, isFirst, isLast, setCurrent }.


Zod schemas

import {
  emailSchema,
  urlSchema,
  phoneSchema,
  slugSchema,
  passwordSchema,
  nonEmptyString,
  z,
} from '@labmgm/forms/schemas';

const schema = z.object({
  email: emailSchema,
  password: passwordSchema, // ≥8 chars, with upper/lower/number
  slug: slugSchema, // lowercase-with-hyphens
  url: urlSchema,
  phone: phoneSchema,
  name: nonEmptyString('Name'), // configurable error message
});

See also

License

MIT © MGM Laboratory