aranlucas/react-hook-form-mantine
Acerca de
React Hook Form bindings for Mantine components, including input, date, slider, select, and group wrappers.
Desarrollo web y de aplicacionesCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- Recopilando historial
- in 15 days
- Recopilando historial
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalReact Hook Form Mantine
React Hook Form Mantine connects Mantine inputs to React Hook Form. Add name and control to bind a field's value and validation.
Install and use
pnpm add react-hook-form-mantine react-hook-form @mantine/core @mantine/hooks @mantine/dates dayjs
The package is ESM and needs Mantine 9 and React 19. @mantine/hooks and dayjs are
Mantine's own peers. The React Hook Form peer range starts at ^7.43, but useController
accepts disabled only from 7.46 and exact only from 7.67. Use 7.46 or later for the
disabled behaviour described below. Exact peer ranges are in package.json.
Load Mantine's styles and wrap your app in MantineProvider, as shown in example/src/main.tsx.
import { useForm } from "react-hook-form";
import { TextInput } from "react-hook-form-mantine";
type Profile = { displayName: string };
export function ProfileForm() {
const { control, handleSubmit } = useForm<Profile>({
defaultValues: { displayName: "" },
});
return (
<form onSubmit={handleSubmit(console.log)}>
<TextInput
name="displayName"
control={control}
label="Display name"
rules={{ required: "Give yourself a name" }}
/>
<button type="submit">Save profile</button>
</form>
);
}
Browse the component demo for props and interactions, or copy the full form with Zod validation. The complete export list is src/index.ts.
Controller lifecycle
Custom onChange and onBlur callbacks run alongside React Hook Form's handlers,
so blur still marks the field touched and runs mode: "onBlur" validation.
disabled is passed to the controller as well as the Mantine control: disabled
field values are omitted from submitted data, following React Hook Form semantics.
Use readOnly where supported if a non-editable value should still be submitted.
Development
Use the Node version in .node-version and the pnpm version in package.json. On a fresh Linux machine, run pnpm exec playwright install-deps chromium after installing dependencies to provision Chromium’s system libraries. GitHub’s Ubuntu runner already supplies the libraries used by the headless tests.
corepack enable
pnpm install --frozen-lockfile
pnpm exec playwright install --only-shell chromium
pnpm typecheck
pnpm lint
pnpm format
pnpm test --run
pnpm build
pnpm exec e2e run
pnpm build-storybook
pnpm format checks formatting; pnpm format:fix writes it. The checks above match CI.
pnpm test runs three Vitest projects: unit (jsdom), example (the example app's tests) and storybook (headless Chromium interactions and accessibility). The E2E web engine installs its pinned headless browser on first use. Run one project with pnpm test:unit --run or pnpm test:storybook --run; use pnpm coverage --project=unit for unit coverage or pnpm coverage for all three.
Storybook
pnpm storybook starts Storybook through Portless; pnpm --dir example dev starts the Vite example. Use the URL printed by Portless. Its first run may ask for sudo to bind port 443 and trust a local certificate. The Storybook dev server exposes its component manifest and stories at /mcp.
pnpm build-storybook produces the static site. GitHub Pages serves main's Storybook from the root of gh-pages. Non-draft, same-repository PRs get /pr-preview/pr-<number>/, linked in a PR comment and removed on close; fork PRs cannot deploy previews.
Storybook's docgen reads prop types through the TypeScript compiler API, which TypeScript 7 doesn't provide. .pnpmfile.cjs gives the docgen packages TypeScript 6 while the project compiles with 7.
Licensed under the MIT License.
Explorar proyectos relacionados
Cargando…