Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 2 months ago
JSON representation

Scroll to the first error in your Formik form and set focus

Awesome Lists containing this project

README

        

# formik-error-focus

[![package version](https://img.shields.io/npm/v/formik-error-focus.svg?style=flat-square)](https://npmjs.org/package/formik-error-focus)
[![package downloads](https://img.shields.io/npm/dm/formik-error-focus.svg?style=flat-square)](https://npmjs.org/package/formik-error-focus)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![package license](https://img.shields.io/npm/l/formik-error-focus.svg?style=flat-square)](https://npmjs.org/package/formik-error-focus)
[![make a pull request](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](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)