How to build a login screen with React and Bootstrap

In this article, lets explore with TipsMake.com how to build a simple yet beautiful login screen using React and Bootstrap 5!

Most websites today require users to register to access certain features or special pages, but building a login screen is one of the most tedious tasks.

 

In this article, let's explore with TipsMake.com how to build a simple yet beautiful login screen using React and Bootstrap 5 !

Required

  • Basic knowledge of HTML, CSS, and Javascript.
  • Basic understanding of React.
  • Set up NodeJS on your computer.

Setting up a React app

Run the following command to create a new React project:

npx create-react-app react-login

Open the project and launch the application:

cd react-login npm start

Once the build process is complete, the application will look like this:

Install Bootstrap

Install Bootstrap using npm:

npm install –save bootstrap

Edit App.js and add an import command for Bootstrap:

 

import "bootstrap/dist/css/bootstrap.min.css"

Go ahead and delete the boilerplate code that your React app adds by default App.js. This file will look like this:

import "bootstrap/dist/css/bootstrap.min.css" import "./App.css" function App() { return } export default App

Establish a roadmap

First, you need to create a new Auth element in Auth.js. We will be working on the Auth element needed to set up the route.

import React from "react" export default function (props) { return Auth Screen }

In a real-world application, you would navigate the user to the login screen if they haven't already. This is where the navigation comes in; run the following command to install it react-router-dom, and restart the React app after the installation is complete.

npm install --save react-router-dom

Edit the file App.jsto set up the login route and default settings. Below is the login interface on the route /auth.

import "bootstrap/dist/css/bootstrap.min.css" import "./App.css" import { BrowserRouter, Routes, Route } from "react-router-dom" import Auth from "./Auth" function App() { return ( } /> ) } export default App

Create a login form

Edit Auth.jsthe initial creation:

import React from "react" export default function (props) { return (

Sign In

   

Forgot password?

 ) }

 

Edit App.cssto include:

.App { background-color: white; } .Auth-form-container { display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; } .Auth-form { width: 420px; box-shadow: rgb(0 0 0 / 16%) 1px 1px 10px; padding-top: 30px; padding-bottom: 20px; border-radius: 8px; background-color: white; } .Auth-form-content { padding-left: 12%; padding-right: 12%; } .Auth-form-title { text-align: center; margin-bottom: 1em; font-size: 24px; color: rgb(34, 34, 34); font-weight: 800; } label { font-size: 14px; font-weight: 600; color: rgb(34, 34, 34); }

If you open the route /auth, you will see the following form:

Add a registration form

Typically, programmers want users to register if they don't already have an account. (Edit element Auth.js:)

import React, { useState } from "react" export default function (props) { let [authMode, setAuthMode] = useState("signin") const changeAuthMode = () => { setAuthMode(authMode === "signin" ? "signup" : "signin") } if (authMode === "signin") { return (

Sign In

 Not registered yet?{" "} Sign Up   

Forgot password?

 ) } return (

Sign In

 Already registered?{" "} Sign In    

Forgot password?

 ) }

Used useStateto switch between login and registration. Now when you access [website] /auth, you can switch between login and registration.

Above is how to create a login/registration UI using React with Bootstrap . I hope this article is helpful to you.

Related posts
  • How to customize Bootstrap with Sass

    bootstrap is a fantastic css framework that can help you create stylish and polished websites. some programmers and development teams find that writing code in bootstrap is easier to edit than regular css.
  • How to add Bootstrap to an Angular application

    angular is a great web development platform. in particular, adding the bootstrap css framework to angular makes the interface elements richer and more dynamic.
  • How to use Bootstrap with HTML

    using bootstrap with html can be quite challenging for beginners. but don't worry, the step-by-step guide below will help you quickly learn how to use bootstrap with html.
  • A compilation of exercises on Bootstrap 5.

    you can test your bootstrap 5 skills with the exercises divided into sections below. solve the exercises by filling in the missing code. you will receive 1 point for each correct answer.
  • Lesson 1: What is Bootstrap 5? How to get started?

    using bootstrap 5 isn't too difficult. this article will tell you what bootstrap 5 is and how to use it.
  • Update the latest Bootstrap

    with the latest version, bootstrap 5.3.0, this framework has introduced a set of exciting new features and powerful improvements for multi-purpose web and app development.
Other Program articles
  • How to use Bootstrap with HTML

    dùng bootstrap với html có thể khá khó với người mới bắt đầu. thế nhưng, đừng lo, hướng dẫn từng bước dưới đây sẽ giúp bạn biết cách sử dụng bootstrap với html nhanh chóng.
  • A compilation of exercises on Bootstrap 5.

    bạn có thể kiểm tra kỹ năng về bootstrap 5 qua những bài tập được chia theo từng phần dưới đây. giải bài tập bằng cách điền vào phần code còn thiếu. bạn sẽ nhận được 1 điểm cho mỗi câu trả lời đúng.
  • Answering frequently asked questions about Bootstrap

    bootstrap là phương tiện phát triển web, ứng dụng phổ biến. nhằm giúp bạn hiểu rõ hơn, tipsmake.com.com sẽ tổng hợp và giải đáp những câu hỏi thường gặp về bootstrap.
  • Lesson 42: Large Grid in Bootstrap 5

    phần bài học bootstrap trước đã giới thiệu cho bạn những ví dụ về hệ thống lưới với các class cho thiết bị nhỏ và trung bình. Ở bài này, chúng ta sẽ tiếp tục tìm hiểu về lagre grid.
  • Lesson 41: Grid Medium in Bootstrap 5

    Ở bài học bootstrap 5 trước, bạn đã biết cách tạo grid với các class cho thiết bị màn hình nhỏ. thế nhưng trên thiết bị trung bình có thiết kế tốt hơn sẽ thường được chia theo 50%/50%.
  • Lesson 40: Small Grid in Bootstrap 5

    tiếp tục bài học về grid trong bootstrap 5, chúng ta sẽ tìm hiểu cách làm lưới grid nhỏ đơn giản nhất. về cơ bản, cách tạo grid nhỏ bằng bootstrap 5 không khó.
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup