Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 4631

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 27, 20242024-11-27T01:47:16+00:00 2024-11-27T01:47:16+00:00

How to create beautiful forms using Contrast in React.

  • 61k

React Bootstrap forms are input-based components which are designed to collect user data. Used as login, subscribe or contact form, all can be easily customized.

While creating CDB, we were aware of their importance in almost every project, so we have put a lot of effort to get them right.

Such constructions like predefined Form logins, Form registers, Form subscriptions or Form contacts and other layout forms varying in their design are all at your disposal. Each of them offers a different type of functionality.

We are going to look at how to create this multi-select drop-down with search today using a react library known as contrast.

Contrast also known as CDBReact is a react library which is an Elegant UI kit with full bootstrap support that has reusable components for building mobile-first, responsive websites, and web apps.
To use the contact forms you need to download the pro version here.

Prerequisites

The contact forms would be built using React, Bootstrap, and CDBReact. You don’t need to have any previous knowledge of CDBReact but the following are necessary:

  • Basic React Knowledge
  • JavaScript knowledge
  • Basic Bootstrap knowledge
  • NPM installed

The page will look like the image below

Alt Text

Setup

First Check that you have node installed. To do this, run the following command in your terminal.

Code

node-v 
Enter fullscreen mode Exit fullscreen mode

This should show you the current version of node you have installed on your machine.
If you don’t have nodejs installed, download it here.
Installing node also installs npm on your PC but you can still confirm using npm-v. Now that we have node installed, we can start up our React project by going to the directory of our choice and running

Code:

npx create-react-app signin-app 
Enter fullscreen mode Exit fullscreen mode

I named the project signin-app but you can use any name of your choice.

Install CDBReact

Now, we have to install CDBReact in our project

Run the following command to install CBDReact using NPM

npm install --save ./path-to-the-cdbreact-pro-tgz-file 
Enter fullscreen mode Exit fullscreen mode

Or using Yarn

yarn add ./path-to-the-cdbreact-pro-tgz-file 
Enter fullscreen mode Exit fullscreen mode

Note that we don’t need to install bootstrap or add it anywhere in our project as CDBReact does that for us upon installation.

Sign in

Let us go ahead to create a file named signin.js which would contain our signin component. We will be writing our code here. Import the various signin components that we’ll be using.

Code:

import React from "react"; import {    CDBInput,    CDBCard,    CDBCardBody,    CDBIcon,    CDBBtn,   CDBLink,    CDBContainer } from "cdbreact-pro"; 
Enter fullscreen mode Exit fullscreen mode

In the code above, we imported the react from react and we also imported

  • CDBInput is used to build the input component
  • CDBCard is used to build the card structure of the sign in
  • CDBCardBody used to build the body of the sign in
  • CDBIcon is component allows you to add icons to the sign in
  • CDBBtn is the component that is used to build buttons in the sign in
  • CDBLink is the component that is used to build links for the sign in
  • CDBContainer is component holds the entire components used in building the sign in components from contrast.

Code:

const Forms = () => {   return (     <CDBContainer>       <CDBCard style={{ width: "30rem" }}>         <CDBCardBody className="mx-4">           <div className="text-center mt-4 mb-2">               <p className="h4"> Sign in </p>           </div>           <CDBInput material hint="E-mail" type="email" />           <CDBInput material hint="Password" type="password" />           <div               className="d-flex flex-wrap justify-content-center align-items-center"           >               <CDBInput type="Checkbox" />               <p className="m-0">Remember me</p>               <CDBLink to="#">Forgot Password ?</CDBLink>           </div>           <CDBBtn               color="dark"               className="btn-block my-3 mx-0" >               Sign in           </CDBBtn>           <p className="text-center">Not a member?             <CDBLink className="d-inline p-0" to="#">               Register             </CDBLink>           </p>           <p className="text-center"> or sign in with</p>           <div className="row my-3 d-flex justify-content-center">             <CDBBtn                 color="white"                 style={{ boxShadow: "none" }}             >                 <CDBIcon fab icon="facebook-f" />             </CDBBtn>             <CDBBtn                 color="white"                 className="m-0"                 style={{ boxShadow: "none" }}             >                 <CDBIcon fab icon="twitter" />             </CDBBtn>             <CDBBtn                 color="white"                 style={{ boxShadow: "none" }}             >                 <CDBIcon fab icon="google-plus-g" />             </CDBBtn>           </div>         </CDBCardBody>       </CDBCard>     </CDBContainer>   ); };  export default Forms; 
Enter fullscreen mode Exit fullscreen mode

In the code above, we created the sign in form and included some styling in the different components in order to make them more appealing.

However, we must first render our component before we can see it display on our screen.

Code:

import './App.css'; import Forms from './signin'; import Reactdom from "react-dom"; import { BrowserRouter as Router } from 'react-router-dom';  function App() {   return (     <Router>       <div className="App">         <Forms />       </div>     </Router>   ); }  export default App;  
Enter fullscreen mode Exit fullscreen mode

The final page should look like the image below

Alt Text

Sign up form

The sign up form is used in several web apps to register for anything or even to recognize users on a platform.

Let's go ahead to create a file named signup.js which would contain our signup component. We will be writing our code here. Import the various signup components that we’ll be using.

Code:

import React from "react"; import {    CDBInput,    CDBCard,    CDBCardBody,    CDBIcon,    CDBBtn,    CDBLink,   CDBContainer } from "cdbreact-pro"; 
Enter fullscreen mode Exit fullscreen mode

In the code above, we imported the react from react and we also imported

  • CDBInput
  • CDBCard
  • CDBCardBody
  • CDBIcon
  • CDBBtn
  • CDBLink
  • CDBContainer components from contrast

Code:

const Forms = () => {   return (     <CDBContainer>       <CDBCard style={{ width: "30rem" }}>         <CDBCardBody className="mx-4">           <div className="text-center mt-4 mb-2">             <p className="h4"> Sign up </p>           </div>           <div className="form-row mb-n4">             <div className="col">               <CDBInput material hint="First name" type="text" />             </div>             <div className="col">               <CDBInput material hint="Last name" type="text" />             </div>           </div>           <CDBInput material hint="E-mail" type="email" />           <p className="text-muted text-center small mt-n4">             At least 8 characters and 1 digit           </p>           <CDBInput material hint="Password" type="password" />           <CDBInput material hint="Phone number" type="text" />           <p className="text-muted text-center small mt-n4">             Optional - for two step authentication           </p>           <div              className="d-flex justify-content-center align-items-center mt-4"           >             <CDBInput type="Forms" />             <p className="m-0">Subscribe to our newsletter</p>           </div>           <CDBBtn             color="dark"             className="btn-block my-3 mx-0"           >               Sign up           </CDBBtn>           <p className="text-center"> or sign up with</p>           <div className="row mb-3 d-flex justify-content-center">             <CDBBtn               color="white"               className="m-0"               style={{boxShadow:"none"}}             >               <CDBIcon fab icon="facebook-f" />             </CDBBtn>             <CDBBtn               color="white"               className="m-0"               style={{boxShadow:"none"}}             >               <CDBIcon fab icon="twitter" />             </CDBBtn>             <CDBBtn               color="white"               className="m-0"               style={{boxShadow:"none"}}             >               <CDBIcon fab icon="google-plus-g"/>             </CDBBtn>           </div>             <p className="text-center m-0">               Already have an account?                <CDBLink className="d-inline p-0" to="#">                 Sign In               </CDBLink>             </p>           <hr/>           <p className="text-center">             By clicking <em>Sign up</em> you agree to our              <CDBLink className="d-inline p-0" to="#">               terms of service             </CDBLink>           </p>         </CDBCardBody>       </CDBCard>     </CDBContainer>   ); };  export default Forms;  
Enter fullscreen mode Exit fullscreen mode

In the code above, the different components are used to create the body of the sign up contact form. We also included some styling and added social media contact in the sign up page.

The next step is to render the signup form in our app.js file.

Code:

import './App.css'; import Forms from './signup'; import Reactdom from "react-dom"; import { BrowserRouter as Router } from 'react-router-dom';  function App() {   return (     <Router>       <div className="App">        <Forms  />       </div>     </Router>   ); }  export default App; 
Enter fullscreen mode Exit fullscreen mode

The signup page should look like the image below.

Alt Text

Newsletter subscription

The newsletter subscription page will house your contact information to help business owners reach their customers and subscribers easily. The page we are going to create will look like the image below

Alt Text

Install CDBReact

Now, we have to install CDBReact in our project. Run the following command to install CBDReact

npm install --save cdbreact 
Enter fullscreen mode Exit fullscreen mode

Or using Yarn

yarn add cdbreact 
Enter fullscreen mode Exit fullscreen mode

Let's go ahead to create a file named newsletter.js which would contain our signup component. We will be writing our code here. First we will Import the various components that we’ll be using.

Code:

import React from "react"; import {    CDBInput,    CDBCard,    CDBCardBody,    CDBIcon,    CDBBtn,    CDBLink,    CDBContainer } from "cdbreact"; 
Enter fullscreen mode Exit fullscreen mode

In the code above, we imported the react from react and we also imported

  • CDBInput
  • CDBCard
  • CDBCardBody
  • CDBIcon
  • CDBBtn
  • CDBLink
  • CDBContainer components from contrast

Now, we are going to write the function that will display the newsletter subscription form.

Code:

const Forms = () => {   return (     <CDBContainer>       <CDBCard style={{ width: "30rem" }}>         <CDBCardBody className="mx-4">           <div className="text-center mt-4 mb-2">             <p className="h4">Subscribe</p>           </div>           <p className="text-center mt-4 font-weight-light">             Join our mailing list. We write rarely, but only the best content.           </p>           <CDBLink className="text-center p-0 font-weight-light" to="#">             See the last newsletter           </CDBLink>           <CDBInput material hint="Name" type="text" />           <CDBInput material hint="E-mail" type="email" />           <CDBBtn             color="dark"             className="btn-block my-3 mx-0" >               Subscribe           </CDBBtn>         </CDBCardBody>       </CDBCard>     </CDBContainer>   ); };  export default Forms; 
Enter fullscreen mode Exit fullscreen mode

We added some styling to the components of the newsletter contact form and links to the social media contact.

Code:

import './App.css'; import Forms from './newsletter'; import Reactdom from "react-dom"; import { BrowserRouter as Router } from 'react-router-dom';   function App() {   return (     <Router>       <div className="App">        <Forms  />       </div>     </Router>   ); }  Reactdom.render(<App />, document.getElementById('root')); 
Enter fullscreen mode Exit fullscreen mode

In the code above, we rendered the newsletter file in the app.js. This doesn’t require a pro version.

The final page will look like this

Alt Text

Conclusion

Contact forms are known to be used in creating sign in forms, sign up forms and newsletter which you can see is easier and much faster to create using contrast and gives you a lot of options to include bootstrap features without having to install it.

Resources

CDBReact Contact Form Docs.

Link to code on github.

Get Contrast Pro.

Create Stunning Websites and Web Apps

Building different custom components in react for your web apps or websites can get very stressful. Thats why we decided to build contrast. We have put together a UI kit with over 10000+ components, 5 admin dashboards and 23 additional different pages template for building almost any type of web app or webpage into a single product called Contrast Pro. Try contrast pro!

Contrast Design Boostrap

Contrast React Bootstrap PRO is a Multipurpose pro template, UI kit to build your next landing, admin, SAAS, prelaunch, etc. project with a clean, well documented, well crafted template and UI components. Learn more about Contrast Pro

Resources

  • Link to the Github Code

  • Link to the Tailwind CSS Modals Docs

  • Get Tailwind CSS PRO

  • Get Contrast PRO

  • Link to the modal documentation

  • How to create Tailwind CSS Modal

  • How to use tailwind CSS in HTML

  • Get Contrast PRO

  • Why tailwind CSS is good

  • How to use Tailwind CSS in Nextjs

  • How to create Tailwind CSS Components for your Website

  • How to create Tailwind CSS Animation

  • Tailwind grid-How to use tailwind CSS grid templates in your project

  • How to create a Beautiful Responsive Navigation bar Using Tailwind CSS

  • Tailwind form-How to create and style a Responsive Form using Tailwind CSS

  • Tailwind CSS Flex: How to use Tailwind CSS Flex

  • How to use tailwind CSS padding, margin and border in your project

  • Tailwind CSS CDN-How to use the Tailwind CSS JIT CDN

  • How to set up your first Tailwind CSS Project

  • How to use Tailwind CSS in HTML

  • Tailwind CSS table-How to Create Tailwind CSS tables

  • How to set up your first Tailwind CSS Project

  • Why is tailwind CSS better than other CSS framework

  • 10 tailwind CSS templates and themes

  • How to add tailwind CSS colors and Fonts to your project

  • Differences between Tailwind CSS and SASS

  • Differences Between Tailwind CSS and Bootstrap

  • 10 Awesome projects built with Tailwind CSS.

  • How to install Tailwind CSS in Vue.js.

  • How to use Tailwind CSS in React

  • How to install Tailwind CSS with Laravel

  • How to create react date picker

  • React bootstrap 5 form-How to create React forms.

  • How to create a beautiful React multiselect.

  • How to create a beautiful React Bootstrap progress bar.

  • How to create a beautiful React Bootstrap select with icons.

  • How to create a beautiful Bootstrap 5 stepper

  • How to create a beautiful React Bootstrap table

  • How to create beautiful React Bootstrap tabs

  • How to create a Beautiful Responsive Navigation bar Using Tailwind CSS

  • Tailwind Modal-How to create a React Modal using Tailwind CSS.

  • How to create a Bootstrap 5 Modal.

  • How to use Tailwind CSS Width

  • Tailwind CSS Colors 3.0

  • How to Create React Tabs with Tailwind CSS

  • How to implement dark mode in React using tailwind css

  • How to Implement a React Step Progress Bar Using Tailwind CSS

programmingreacttailwindcsswebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.