If using conditional SCSS, consider overriding the variables

When working with React state, I am passing a list and calling the component where needed.

comments: {
                elementLabel: "Comments",
                elementType: 'textarea',
                className: "form-control",
                elementConfig: {
                    placeholder: "comments",
                    name: "comments",
                    id: "comments",
                       },
                value: '',
                rows: "5",
                cols: 5,
                form_value: "",
                validation: {
                },
                valid: false,
                touched: false,
                isChanged: true,
                errorMessage: "",
                changed: (event) => this.inputChangedHandler(event, "comments"),
                blured: (event) => this.inputBlurHandler(event, "comments")
            },

If the below value is called, I want to set the following in the class:

.form-control {
    height: 34px !important;
  } instead of this i want to set `80px`

The full SCSS class can be found here. How can I achieve this? If I try to add a new class and render it with a div, it does not make any changes as it gets overwritten back.

<div className="form-row mb-3">
                                <div className="col-md-12">
                                    <div className="ftm-form">
                                        <Input
                                        className="form-control-height"
                                            {...this.state.comments}
                                        />
                                    </div>
                                </div>
                            </div>

Before changes enter image description here After your changes enter image description here

Answer №1

Firstly, it is important in CSS to accurately define your classes like so:

.form-control {
    height: 34px;

    &.form-control-height {
      height: 80px;
    }
  }

When working with React code, be mindful not to overwrite your className with your state. Consider refactoring your code as follows:

<div className="form-row mb-3">
  <div className="col-md-12">
    <Input {...this.state.comments} className="form-control form-control-height" />
  </div>

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

Is it possible to eliminate the *:after effect for specific elements in my CSS?

I struggle with CSS, so I decided to use a library that includes the following CSS code: *, *:before, *:after { box-sizing: inherit ; } While this code works well for some views, it messes up others and is unnecessary for some. For instance, in this b ...

Leaflet OSM: Adjust map focus to the polygon's center

Looking to create an HTML file that integrates the Leaflet library to display an OpenStreetMap view with a centered polygon? I've been following a helpful discussion, but still unsure about how to center and autozoom an arbitrary polygon on the map. A ...

Is there a way to effectively communicate and pass state information between sibling components in React?

Is there a way to share state data between two React component functions that are both children of another component? I am new to React and have tried exporting a const from my App.jsx file with a structure containing the state properties, but when queri ...

What is the best way to use jQuery to increment the number in an input field by a specific value?

My goal is to utilize jQuery to increment a number in an input field and then display the updated value in the same input field. The specific id of this input field is "total". Here's my attempt so far: function addBag(){ var bagprice = 79.99; ...

The deletion or removal of the delete/edit button for authentication purposes causes comments to be improperly displayed on the

It's interesting how the comment section behaves differently based on whether the user is the owner of the comments or not. When I, as the user who posted the comments and has permission to see the edit/delete button, view the section, everything look ...

What is the best way to focus the video on its center while simultaneously cropping the edges to keep it in its original position and size?

I'm trying to create a special design element: a muted video that zooms in when the mouse hovers over it, but remains the same size as it is clipped at the edges. It would be even more impressive if the video could zoom in towards the point where the ...

Updating elements within an array on the fly

In this scenario, let's consider two arrays: array A = [2, 5, 6] and array B = [1, 2, 3, 4, 5, 6, 7, 8]. The values of array B are initially hidden within boxes and become revealed when clicked. The goal is to replace certain values in array B with un ...

Unable to retrieve HTTP call response during debugging, although it is visible in the browser

When I send an HTTP request to create a record, I am able to see the added record id in the Network section of browsers like Chrome and Firefox. However, when I try to debug the code and retrieve the same id value, I encounter difficulties. I have tried us ...

I'm facing an issue with this error message - DiscordAPIError: Unable to send a message that is empty. How can I

What's the solution to this issue? Error: UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message Code: let y = process.openStdin() y.addListener('data', res => { let x = res.toString().trim().split(/ +/g) ...

Retrieve the value of a duplicated object key from a JSON and replace it with just one unique value

In my current project, I am faced with the challenge of extracting duplicate object keys' values from a JSON dataset and replacing them with only one value. My goal is to ultimately return these unique key-value pairs as an array. NOTE: This data has ...

React - useEffect is being called unnecessarily multiple times

I'm currently facing an issue with rendering a component in my project. The main purpose of this component is to retrieve data from a 3rd party API and then present it in an HTML table (MatchTable component). Profile.js // imports export const Profi ...

Employing jQuery to attach a new div to a dynamically generated div following a successful AJAX request

Currently, I am utilizing the marvelous WP-Polls plugin for WordPress, which boasts an innovative AJAX polling system. My main objective is to append a hidden div (.comment-block) to a fresh div (.voted) that will be dynamically injected into the DOM by th ...

Hiding a div using swipe gestures in Angular

What am I trying to achieve? I aim to hide a div when swiped right. This specific action will close the pop-up that appears after clicking a button. What tools are at my disposal? I am utilizing Ionic framework for this task. Within my app.js, I have i ...

Is it possible for the vertical borders of <span> to overlap?

When nesting multiple spans within each other and giving them borders, their horizontal borders overlap by default while their vertical borders stack. Check out a live example on JsFiddle: https://jsfiddle.net/4un9tnxy/ .html: <span><span>a& ...

Encountering a problem with AngularJS ui router templates

I have defined the following routes in my project: $stateProvider .state('access', { abstract: true, url: '/access', templateUrl: 'login.html' }) .state('access.signin', { ...

Issues with NodeJs Express routes execution

After testing, I found that only the default route "/" is working in my code. Many similar issues involve routers being mounted to paths like "/auth" or "/user". Even when I tested the default router mounted to "/", it still isn't functioning properly ...

myUseHook is experiencing technical difficulties

In my Next.js project, I have created a custom hook called useAlert to control the behavior of my alert component. import { useEffect, useState } from 'react'; const useAlert = () => { const [isVisible, setIsVisible] = useState(false); c ...

New to Angular: Getting Started with NgModel Binding

Novice query: I am facing an issue with a simple input type=text element linked to ng-model="xyz.zyx", where xyz refers to an object. In my controller, I initialize this object and set the value for the property zyx as shown below: xyz { zyx: $scope.zz ...

Bring in SASS variables to enhance Material UI theme in NextJS

Within my project, I currently have the following two files: materialTheme.ts import { createMuiTheme, Theme } from "@material-ui/core/styles"; const theme: Theme = createMuiTheme({ palette: { primary: { main: "#209dd2", contras ...

What benefits does Next.js offer compared to using plain React for rendering 3D models with three.js?

In a previous project, I utilized a 3D product configurator application and am now curious about the potential performance improvements (specifically FPS) that "server-side rendering" with Next.JS could provide compared to using plain React. ...