How can I modify the TextField's borderBottom style to be 'none' when it is disabled?

While working within a data cell, I encountered an issue with stacking text. To workaround this obstacle, I opted to create a text field, assign it a value and helper text, disable the field, and change the text color to black when disabled. My current challenge is altering the bottom border to 'none', as I suspect that it's responsible for creating the dashed line under the input value text.

const DarkerDisabledTextField = withStyles({
    root: {
        marginRight: 8,
        "& .MuiInputBase-root.Mui-disabled": {
            color: 'black',
            fontSize: '16px',
            borderBottom: 'none',

        }
    },
    underline: {
        "& .MuiInputBase-root.MuiInput-outlined": {

            borderBottom: 'none',

        }
    }
})(TextField);

The above snippet showcases how I created and styled my text field. However, the underline key did not produce the expected results based on my research.

Here are the attempts I've made so far with my text field:

<DarkerDisabledTextField
    title={params.data.name}
    disabled
    defaultValue={params.data.name}
    helperText={title}
    fullWidth
 />

Answer №1

My recommendation is to use the prop solution provided below.

<DarkerDisabledTextField
  helperText="helper text"
  disabled={isDisabled}
  InputProps={isDisabled ? { disableUnderline: true } : {}}
/>

If you prefer using the withStyles method, consider checking out the :before option.

const DarkerDisabledTextField = withStyles({
  root: {
    marginRight: 8,
    "& .MuiInputBase-root.Mui-disabled:before": {
      color: "black",
      fontSize: "16px",
      borderBottom: "none"
    }
  }
})(TextField);

Here's a link to an applied codesandbox for reference.

Answer №2

When incorporating Mui v5 inputs with createTheme, I made the following adjustments to components:

createTheme({
    components: {
        MuiInputBase: {
            styleOverrides: {
                root: {
                    '&.MuiInput-root.Mui-disabled': {
                        ':before': {
                            borderBottomStyle: 'solid'
                        }
                    }
                }
            }
        }
    }
});

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

I am currently struggling with a Typescript issue that I have consulted with several individuals about. While many have found a solution by upgrading their version, unfortunately, it

Error message located in D:/.../../node_modules/@reduxjs/toolkit/dist/configureStore.d.ts TypeScript error in D:/.../.../node_modules/@reduxjs/toolkit/dist/configureStore.d.ts(1,13): Expecting '=', TS1005 1 | import type { Reducer, ReducersMapO ...

Ensuring that nested objects in an absolutely positioned element do not wrap, clear, or stack

Looking for some assistance with my tooltip menu. The problem I'm facing is that my links keep wrapping to a new line, and I can't figure out how to prevent this. I've already attempted using display:inline and float:left on the links within ...

Efficient ways to clear all input fields within a React div component

import "./App.css"; import { useState } from "react"; import { useSelector, useDispatch } from "react-redux"; import { addUser} from "./features/Users"; function App() { const dispatch = useDispatch(); const use ...

I am facing an issue with not being able to access session.payment_intent within Stripe

I integrated Stripe wallet into my Next.js project and created a test account for development purposes. Here is the server-side code: checkout_session.js const stripe = require("stripe")( "sk_test_xxxxx" ); export default async fun ...

Creating a spinning Cube with separate fields for x, y, and z rotation speeds: a step-by-step guide

After dabbling in Java, Visual Basic, HTML, and CSS, I'm now looking to create an interface featuring a central spinning cube with 3 fields to control its x, y, and z rotation speeds. Can you suggest which language would be the best fit for this proje ...

"Adjusting Material UI Select Size - A Guide to Resizing Your

Struggling with getting Material UI selects to work properly with height and width using 'vh' and 'vw', as well as adjusting text size with 'vh'. The boxes have the correct size, but the label text is no longer centered due t ...

Configuring React on the client-side along with Express.js on the backend using Webpack 4

I have successfully configured React and webpack. Below is my webpack.config.js file: const HtmlWebPackPlugin = require('html-webpack-plugin'); const path = require('path'); module.exports = { entry: { index: './client/inde ...

Turn off hover effect for MUI DataGrid

I'm having trouble figuring out how to disable the hover effect on a row in the MUI Datagrid. I've searched through the API documentation but couldn't find a straightforward solution. Any suggestions on how to achieve this? <DataGrid ...

How can the parent state be updated in ReactJS when the child state changes?

I am facing an issue with a component called AppBarRight. When a button is clicked, a backend function should be called and then its parent component, AppBar, should render another component called MyList. However, the provided code is not working as expec ...

Issue with Firefox position: absolute not producing the desired outcome

I am working on a webpage where I want to put a label over an image. I was able to achieve this using position: absolute for the label and float: left for the img tag. This method worked perfectly in most browsers, except for Firefox (both version 3 and 4) ...

Display a list with a set limit and an option to show more by clicking

I am currently struggling to develop a list of items that displays 3 items per row, and when the "show more" button is clicked, another 3 items should be displayed. My issue arises when using map and slice, as this method results in rendering 3 of the same ...

Issue with the Material UI theme module enhancement feature not functioning as expected

I've been researching the MUI documentation, blogs, and various posts on Stackoverflow, but despite my efforts, I can't seem to get my vscode intellisense/typescript to recognize the changes I've made. These are fairly straightforward modif ...

design style of an activated material-ui button

I am currently working on implementing appbar buttons that appear differently when active. This is my first experience with material-ui, and I have found that the documentation can be somewhat unclear. My goal is to add an underline to the button that is ...

What steps should I take to present the information contained in an array retrieved from an API?

Hey there! I'm currently facing an issue with displaying the data retrieved from the punkbeer API. Any assistance or guidance would be greatly appreciated. import { useEffect, useState, Fragment } from 'react'; import { Switch, Link, Route, ...

How can I adjust the Bootstrap container width without it changing when resizing the browser window?

As I work on developing my website, I am utilizing Twitter's bootstrap grid system. Despite my efforts, I have been unable to find a solution for fixing the width of the site. My goal is to lock the size in place so that it remains constant regardless ...

What is the best way to assign a unique background color to each individual card in my card list?

I have a list of cards and I want to assign a unique color to each card in the list. I attempted to do this on my own, but it ended up being more complex than I anticipated. Here is the list of cards: return ( <Container> <Row className=&qu ...

Issue with the react-scripts package when running the npm build command

Attempting to compile a project for the first time on a new application using npm run build resulting in the following error: client/node_modules/.bin/react-scripts: line 11: exec: node: not found So far, I have tried: chmod +x node_modules/.bin/react-sc ...

Creating a tree with branches using divs: a comprehensive guide

I have been tasked with designing a tree structure for a project that will visually represent the results of a quiz. The tree needs to have branches on both sides, featuring 4 main branches, each with 5 smaller branches extending from them. Additionally, I ...

Jquery Menu featuring subitems aligned to the right

I am experiencing an issue with my drop-down menu in ie6. The subitems menus are shifted to the right, rendering the menu useless. Here is the HTML code: <div id="navigation"> <a href="<?php echo base_url();?>" class="singl ...

The geocoder-autocomplete feature in ReactJS is now experiencing a sudden Network Error in Firefox

I followed the tutorial provided by HERE and successfully implemented the solution for street address validation using ReactJS and HERE geocoder autocomplete. Everything was working fine on Firefox and Chrome until a few weeks ago when it suddenly stopped ...