https://github.com/tiaanduplessis/formik-error-focus
Scroll to the first error in your Formik form and set focus
https://github.com/tiaanduplessis/formik-error-focus
error focus formik scroll-to
Last synced: 11 days ago
JSON representation
Scroll to the first error in your Formik form and set focus
- Host: GitHub
- URL: https://github.com/tiaanduplessis/formik-error-focus
- Owner: tiaanduplessis
- License: mit
- Created: 2019-06-18T13:52:43.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-22T01:26:56.000Z (about 3 years ago)
- Last Synced: 2025-04-23T11:41:25.736Z (30 days ago)
- Topics: error, focus, formik, scroll-to
- Language: TypeScript
- Size: 225 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# formik-error-focus
[](https://npmjs.org/package/formik-error-focus)
[](https://npmjs.org/package/formik-error-focus)
[](https://github.com/RichardLitt/standard-readme)
[](https://npmjs.org/package/formik-error-focus)
[](http://makeapullrequest.com)Scroll to the first error in your Formik form and set focus
## Table of Contents
- [formik-error-focus](#formik-error-focus)
- [Table of Contents](#table-of-contents)
- [👀 Background](#-background)
- [⚙️ Install](#️-install)
- [📖 Usage](#-usage)
- [📚 API](#-api)
- [💬 Contributing](#-contributing)
- [🪪 License](#-license)## 👀 Background
Wrapper around [scroll-to-element](https://www.npmjs.com/package/scroll-to-element) that scrolls to the first error element in Formik.
## ⚙️ Install
Install the package locally within you project folder with your package manager:
With `npm`:
```sh
npm install formik-error-focus
```With `yarn`:
```sh
yarn add formik-error-focus
```With `pnpm`:
```sh
pnpm add formik-error-focus
```## 📖 Usage
```js
import React from "react";
import { Formik, Field, Form } from "formik";
import FormikErrorFocus from "formik-error-focus";export const Signup = () => (
My Uncool Persisted Form
console.log(values)}
initialValues={{ firstName: "", lastName: "", email: "" }}
render={(props) => (
Submit
)}
/>
);
```## 📚 API
For all configuration options, please see the [API docs](https://paka.dev/npm/formik-error-focus).
## 💬 Contributing
Got an idea for a new feature? Found a bug? Contributions are welcome! Please [open up an issue](https://github.com/tiaanduplessis/formik-error-focus/issues) or [make a pull request](https://makeapullrequest.com/).
## 🪪 License
[MIT © Tiaan du Plessis](./LICENSE)