Last active
August 26, 2024 06:21
-
-
Save bnymn/11be19a276711e7ce24a283868ead282 to your computer and use it in GitHub Desktop.
Partial login form after bootstrap applied
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Formik, Field, Form, FormikHelpers } from 'formik'; | |
import styles from './login-form.module.css' | |
interface Values { | |
username: string; | |
password: string; | |
} | |
export default function LoginForm() { | |
return ( | |
<div className={styles.login_box + ' p-3'}> | |
<h1 className="display-6 mb-3">Login</h1> | |
<Formik | |
initialValues={{ | |
username: '', | |
password: '', | |
}} | |
onSubmit={( | |
values: Values, | |
{ setSubmitting }: FormikHelpers<Values> | |
) => { | |
setTimeout(() => { | |
alert(JSON.stringify(values, null, 2)); | |
setSubmitting(false); | |
}, 500); | |
}} | |
> | |
<Form> | |
<div className="mb-3"> | |
<Field className="form-control" id="username" name="username" placeholder="Username" aria-describedby="usernameHelp" /> | |
</div> | |
<div className="mb-3"> | |
<Field className="form-control" id="password" name="password" placeholder="Password" type="password" /> | |
</div> | |
<button type="submit" className="btn btn-primary">Login</button> | |
</Form> | |
</Formik> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
xxx