{"id":19732964,"url":"https://github.com/adelpro/simple-styled-login-form","last_synced_at":"2026-06-10T03:30:57.232Z","repository":{"id":171047165,"uuid":"559245062","full_name":"adelpro/Simple-styled-login-form","owner":"adelpro","description":"Simple login form using ReactJS using useRef, useState","archived":false,"fork":false,"pushed_at":"2022-10-29T16:16:12.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T04:01:01.228Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adelpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-29T14:09:52.000Z","updated_at":"2023-05-27T11:49:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"bbdcebc1-5b01-4a4f-a292-f512902cf778","html_url":"https://github.com/adelpro/Simple-styled-login-form","commit_stats":null,"previous_names":["adelpro/simple-styled-login-form"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adelpro/Simple-styled-login-form","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adelpro%2FSimple-styled-login-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adelpro%2FSimple-styled-login-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adelpro%2FSimple-styled-login-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adelpro%2FSimple-styled-login-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adelpro","download_url":"https://codeload.github.com/adelpro/Simple-styled-login-form/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adelpro%2FSimple-styled-login-form/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34136112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T00:28:40.731Z","updated_at":"2026-06-10T03:30:57.214Z","avatar_url":"https://github.com/adelpro.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple styled login form with ReactJS\n\n\nIn this practical tutorial, we will create a login form using ReactJS.\n\nThis form will contain:\n\n✓ Username input with label\n\n\n✓ Password input with label\n\n✓ Toggle Show Hide Password with svg icons\n\n✓ Inputs have two CSS on focus animations\n\n\n✓ Button with two CSS on hover animations\n\n\n✓ Responsive size for small screens\n\n\n✓ To keep the project simple we will only add logics to make the form functional\n\n\nThe project contain two components and one style.css :\n\n## App\n\n\n```\nimport Login from \"./Login\";\nexport default function App() {\nreturn ( \u003cLogin\u003e )\n}\n```\na simple App.js file with the \u003cLogin\u003e component.\n\n## Login\n\n```\nimport “./styles.css”;\nimport { useEffect, useRef, useState } from “react”;\nexport default function Login() {\nconst usernameRef = useRef();\nconst [username, setUsername] = useState(“”);\nconst [password, setPassword] = useState(“”);\nconst handleSubmit = async (e) =\u003e {\ne.preventDefault();\nconsole.log(“handle submit”);\n};\nuseEffect(() =\u003e {\n//usernameRef.current.focus();\n}, []);\nreturn (\n\u003cdiv className=”App”\u003e\n  \u003ch1\u003eLogin\u003c/h1\u003e\n  \u003cform onSubmit={handleSubmit} className=”form__container”\u003e\n    \u003cdiv className=”form__controls”\u003e\n      \u003clabel htmlFor=”username”\u003eUsername\u003c/label\u003e\n      \u003cinput\n      ref={usernameRef}\n      type=”text”\n      id=”username”\n      value={username}\n      onChange={(e) =\u003e setUsername(e.target.value)}\n      /\u003e\n    \u003c/div\u003e\n   \u003cdiv className=”form__controls”\u003e\n    \u003clabel htmlFor=”password”\u003ePassword\u003c/label\u003e\n    \u003cinput\n    id=”password”\n    type=”password”\n    value={password}\n    onChange={(e) =\u003e setPassword(e.target.value)}\n    /\u003e\n  \u003c/div\u003e\n  \u003cdiv className=”form__controls”\u003e\n   \u003cbutton className=”button”\u003eLogin\u003c/button\u003e\n  \u003c/div\u003e\n\u003c/form\u003e\n\u003c/div\u003e\n);\n}\n```\nWe will explain the CSS styling\n\n### for the form\n\n```\n\u003cform onSubmit={handleSubmit} className=”form__container”\u003e\n```\nForm contain onSubmit function with a className “form__container”\n\n```\n.form__container {\ndisplay: flex;\nflex-direction: column;\njustify-content: center;\nalign-items: center;\nborder: 1px solid #ccc;\nborder-radius: 5px;\nmargin: auto;\npadding: 10px;\nwidth: 450px;\n}\n@media only screen and (max-width: 480px) {\n.form__container {\nwidth: 290px;\n}\n....\n}\n```\nIn the first part .form__container {}\n\n. Center the form (margin:auto)\n\n. Center all the controls with Flex CSS\n\n. Give a nice rounded border\n\n. A fixed width of 450px\n\n\nIn the second part @media only screen and (max-width: 480px) {}\n\n.Will adjust the width of the form (to 290px) for small screens ( under 480px)\n\n```\n\u003cdiv className=”form__controls”\u003e\n```\n\nForm controls\nWith act like a container for the form controls: input, label, button\n\n```\n.form__controls {\nmargin: 10px;\npadding: 2px;\n}\n```\n\n```\n.form__controls {}\n```\ncontain margin and padding\n\n### Inputs\n\n```\n.form__controls \u003e input{}\n```\n\n\u003eThe “\u003e” Sign in CSS :\n\n\u003eIt means target elements which are DIRECT children of a particular \u003eelement.\n\n. Gives styling to the input with a fixed width and height\n\n. A nice rounded gray border\n\n. And the line “transition: 0.1s ease-in-out;” with determine the duration of the CSS animation (transition) with is 0.1s with “ease-in-out” effect (you can find more information here)\n\n\nThis CSS class change to a smaller width on small screens\n\n```\n@media only screen and (max-width: 480px) {\n  .form__controls \u003e input {\n    width: 150px;\n  }\n}\n```\n\nThe on focus animation effect in inputs:\n\n```\n.form__controls \u003e input:focus {\n  outline: 2px solid #84c586;\n  outline-offset: 1px;\n  transform: scale(1.05);\n}\n```\nThe two lines with “outline” will give a nice green border to the inputs when selected.\n\nthe transform line will grow up the input when focussed using scale() CSS function\n\n### Labels\n\n```\n.form__controls \u003e label {\nmargin-right: 10px;\nwidth: 100px;\nheight: 30px;\n}\n```\ncontain the styling of the label\n\n### Buttons\n\n```\n.button {\nheight: 40px;\nwidth: 100px;\nfont-size: 1.2rem;\nborder-radius: 5px;\ncursor: pointer;\ntransition: 0.1s ease-in-out;\n}\n.button:hover {\nbackground-color: #84c586;\ncolor: whitesmoke;\nborder-color: gray;\ntransform: scale(1.05);\n}\n```\n\nWe have the class:\n\n```\n.button {}\n```\nwith gives the button a fixed width and height with a nice rounded border\n\nand the “transition” will animate the button with a duration of 0.1s and with an “ease-in-out” effect\n\n```\n.button:hover {}\n```\nwill give the background of the button a green color and a grow animation effect with scale() CSS function.\n\nFor the logics on this form\n### inputs\n\n```\n\u003cinput\nid=”password”\ntype=”password”\nvalue={password}\nonChange={(e) =\u003e setPassword(e.target.value)}\n/\u003e\n```\nFor each input we created a separated state using react useState\n\nand associate it the the value and onChange properties of the input\n\nFor the username input we use a “ref” to put the focus on it when the component render.\n\n```\nconst usernameRef = useRef();\n....\nuseEffect(() =\u003e {\nusernameRef.current.focus();\n}, []);\n```\nWe added onClick function to submit the form with a simple console.log function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadelpro%2Fsimple-styled-login-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadelpro%2Fsimple-styled-login-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadelpro%2Fsimple-styled-login-form/lists"}