no visible text displayed within an input-label field

Currently, I have started working on a multi-step form that is designed to be very simple and clean. However, I am facing an issue where nothing is being displayed when I click on the next arrow.

I am puzzled as to why it's not even displaying the text at the moment.

Below is the code snippet:

import React from 'react'
import './ClassCreationForm.css'

class ClassCreationForm extends React.Component {

    constructor(props, context) {
        super(props);
        this.state = {
            questions: [
                { phrase: 'Enter Your First Name' },
                { phrase: 'Enter Your Last Name' },
                { phrase: 'Enter Your Email', pattern: /\S+@\S+\.\S+/ },
                { phrase: 'Create A Password', type: 'password' }
              ],
              shakeTime: 100,
              switchTime: 200,
              position: 0,
              currentAnswer: ''
        };
    }

  handleKeyUp = (event) => {
    const { value, keyCode } = event;
    this.setState({
      currentAnswer: value
    });
    if (keyCode === 13) {
      this.validate();
    }
  }

  handleNextClick = (event) => {
    this.validate();
  }

  validate = () => {
    console.log(this.state.currentAnswer);
  }

  render() {
    const { questions, position } = this.state;
    const { phrase, type, pattern } = questions[position];
 
    return (
      <div id="container">
        <h1 className="logo">Class ClassCreationForm</h1>
        <div id="form-box">
          <i id="prev-btn" className="fas fa-arrow-left"></i>
          <i 
            id="next-btn" 
            className="fas fa-arrow-right"
            onClick={this.handleNextClick}
          ></i>
          <div id="input-group">
            <input 
              id="input-field" 
              type={type || 'text'}
              onKeyUp={this.handleKeyUp}
              required 
            />
            <label id="input-label">
              { phrase }
            </label>
            <div id="input-progress"></div>
          </div>
          <div id="progress-bar"></div>
        </div>
      </div>
    )
  }

}

export default ClassCreationForm

Additionally, here is the associated CSS code:



h1.logo {
  color: #333333;
  font-family: 'Fredoka One', cursive;;
  font-size: 4em; }

h1.end {
  position: relative;
  color: #fff;
  opacity: 0;
  transition: 0.8s ease-in-out; }

#container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: top;
  align-items: center; }

#form-box {
  background: #fff;
  position: relative;
  width: 600px;
  border-top-right-radius: 18px;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.03), 0 6px 10px 5px rgba(0, 0, 0, 0.03), 0 8px 10px -5px rgba(0, 0, 0, 0.03);
 }

#form-box.close {
  width: 0;
  padding: 0;
  overflow: hidden;
  transition: 0.8s ease-in-out;
  box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0); }

#next-btn {
  position: absolute;
  right: 20px;
  bottom: 10px;
  font-size: 40px;
  color: #dbdada; 
  float: right;
  cursor: pointer;
  z-index: 2; }
  #next-btn:hover {
    color: #ff7255; }

#prev-btn {
  position: absolute;
  font-size: 18px;
  left: 30px;
  top: 12px;
  z-index: 2;
  color: #dbdada;
  float: right;
  cursor: pointer; }
  #prev-btn:hover {
    color: #ff7255; }

#input-group {
  position: relative;
  padding: 30px 20px 20px 20px;
  margin: 10px 60px 10px 10px;
  opacity: 0;
  transition: opacity 0.3s ease-in-out; }
  #input-group input {
    position: relative;
    width: 100%;
    border: none;
    font-size: 20px;
    font-weight: normal;
    outline: 0;
    background: transparent;
    box-shadow: none; }
  #input-group #input-label {
    position: absolute;
    pointer-events: none;
    top: 32px;
    left: 20px;
    font-size: 20px;
    font-weight: bold;
    color: red;
    transition: 0.2s ease-in-out; }
  #input-group input:valid + #input-label {
    top: 6px;
    left: 42px;
    margin-left: 0 !important;
    font-size: 11px;
    font-weight: normal;
    color: #ff7255; }

#input-progress {
  border-bottom: 3px solid #ff7255;
  width: 0;
  transition: width 0.6s ease-in-out; }

#progress-bar {
  position: absolute;
  background: #fcae9e;
  height: 10px;
  width: 0;
  transition: width 0.5s ease-in-out; }

.close #next-btn,
.close #prev-btn {
  color: #ff7255; }

.error #input-progress {
  border-color: #ff7255; }

.error #next-btn {
  color: #ff7255; }

@media (max-width: 600px) {
  #form-box {
    width: 80%; } }

You can see how the form looks like in the image below: https://i.stack.imgur.com/THnot.png

Answer №1

The opacity of your input group is currently set to 0, causing the label and input to be hidden. Without any triggers in your code to change the opacity value, I adjusted it to 1 temporarily to reveal where the input and label are located:

#input-group {
  position: relative;
  padding: 30px 20px 20px 20px;
  margin: 10px 60px 10px 10px;
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

https://jsfiddle.net/abc123xyz/2/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Attempting to remove certain selected elements by using jQuery

Struggling to grasp how to delete an element using jQuery. Currently working on a prototype shopping list application where adding items is smooth sailing, but removing checked items has become quite the challenge. Any insights or guidance? jQuery(docume ...

Struggling to pass along the URL value from a promise to various modules within Express is proving to be quite a challenge for me

I've been working on an app using ngrok, following a guide from Phil on setting up ngrok with nodemon. You can find the link to the post here. I need to have access to the URL received from the promise in the bin folder throughout the app server so t ...

experiencing an excessive amount of re-renders after transferring data to a distinct component

At the moment, I have implemented this logic to display data based on the results of a graphql query, and it is working well: const contacts = () => { const { loading, error, data } = useUsersQuery({ variables: { where: { id: 1 }, ...

The Node.js POST request is unexpectedly returning 'undefined'

I'm currently working on a project for an online course and I'm encountering an issue with making an API call. It seems that I am getting undefined responses to my post request because the user input is not being retrieved properly. Below are the ...

JQuery is having issues with $(this) and the find function not working properly

I am attempting to access a child of the div with the class form-group, specifically, I want to display the value of the input element. <div class="form-group"> <label>text</label> <input name="text" type="text" class="form-co ...

Troubleshooting a Border Problem in CSS

Just joined this site and I'm new to coding, eager to learn more. I'm trying to make the border of this grey box grey, with the rest being blue. I've searched online but can't find exactly what I need. The grey area is 200px wide and ...

Exploring TypeScript implementation of Redux toolkit's store

I'm currently diving into the world of Redux in React + TypeScript by following the tutorials provided by Redux Toolkit. I am attempting to implement it in a sample application. My main struggle lies with typings related to the store and the mappStat ...

What is the best way to ensure that a Flex div and its child images stay confined within the boundaries of its parent container?

I'm struggling to create a responsive grid of images. I can't get the images to be both responsive with max-height and max-width, while also making sure the parent div takes up their full width. On the other hand, if I make the parent div the cor ...

Mastering the art of passing props in VueJS

My setup in the App is quite straightforward, with two main components: The HelloWorld component and a dialog component. The dialog component receives props from the HelloWorld component. The data in the HelloWorld component is rendered by looping over an ...

Transform the hue of symbols within D3-legend

I am attempting to modify the appearance of symbols in a legend. The variable below represents the available symbol types: var symbolTypes = { "triangleUp": d3.svg.symbol().type("triangle-up"), "circle": d3.svg.symbol().type("circle") }; I use this varia ...

issue with brightcove player's complete event not triggering upon video replay

I have a videoplayer with an event listener added in an onTemplateReady function. Upon completion of the video, I want to replay it: videoPlayer.addEventListener(brightcove.api.events.MediaEvent.COMPLETE, completedCallback); function completedCallback(){ ...

Distinctive titles for JavaScript constructors/prototypes compared to classes

When working with JavaScript ES6, classes allow us to write code like this: class RectangularShape { constructor(height, width) { this.height = height; this.width = width; } getArea() { return this.height * this.width } static some ...

Obtain a multiline match using regular expressions

Is there a way to use regex to match only multi-line strings without matching single-line strings as well? Here is the current regex I am using: Regex ('|"|`)[\s\S]*?(\1) Test string "not a match" "need to match&qu ...

What is the best way to define the height in a react project?

Greetings on this fine Friday. I've experimented with various options, but none of them appear to have any effect. "height": "100%" "height": "450px" "height": "auth" I would rather avoid a ...

Retrieve the data stored in an array of objects

code props.thumbnails.forEach(value=>{ console.log(value.photo.thumbnail_url); }) error TypeError: Cannot read property 'thumbnail_url' of undefined Trying to loop through props.thumbnails array and access the thumbnail_url pro ...

Vue.js: The href attribute in a link is different from the data

Having <a> href tag below, clicking will redirect to www.duckduckgo.com, with the value of page.publicWebsite being displayed as well. {{page.publicWebsite}} shows www.duckduckgo.com. Is everything functioning correctly? https://i.stack.imgur.com/ ...

Is there a way to include a minimize button on a MaterialUi Table enclosed in a Paper component for easy table reduction?

I am trying to add a minimize button to either minimize my MaterialUi Table or the Paper component that wraps it. Here is the code I have so far: <TableContainer component={Paper} style={{maxHeight:'inherit', maxWidth:'inherit', boxS ...

Exploring the Differences: NodeJS and ExpressJS for Server-Side and Client-Side HTML Rendering

Embarking on my journey with Node.js, I find myself grappling with the concept of server-side and client-side HTML pages. My objective is to hone my skills by creating an e-commerce web store. The technology stack that I have set my sights on includes Node ...

Guide on serializing an object containing a file attribute

I'm currently working on creating a small online catalog that showcases various housing projects and allows users to download related documents. The data structure I am using is fairly straightforward: each project has its own set of properties and a ...

Constructing and rendering PDFs with c# and React

I am currently working on a project involving the generation of a customized PDF file based on user input and database information. I am seeking guidance on executing this project and deciding on which frameworks to utilize. The project is divided into thr ...