Getting rid of the border on a material-ui v4 textbox

I am currently using Material-UI version 4 and have not upgraded to the latest mui v5.

I have experimented with various solutions, but so far none have been successful. My goal is simply to eliminate or hide the border around the textfield component.

<TextField
  disabled={true}
  variant="standard"
  InputProps={{ 
    style: { backgroundColor: '#d6eaf8', fontSize: '18px', color: 'black' },
             underline: {
                "&&&:before": {
                      borderBottom: "none"
                },
                "&&:after": {
                      borderBottom: "none"
                }
             }                          
           }}                   
 />

Answer №1

To remove the underline border from material ui, simply add the property "disableUnderline: 'true'" like this:

<TextField
 disabled={true}
 variant="standard"
 InputProps={{
   disableUnderline: 'true',
   style: {
     backgroundColor: "#d6eaf8",
     fontSize: "18px",
     color: "black"
   }
 }}
/>

If you want all TextInputs to have a consistent look, consider setting up a custom Theme.

updated:

An alternative method to remove the border is by adjusting CSS Global classes as follows:

  const StyledTextField = withStyles({
    root: {
      "& .MuiOutlinedInput-root": {
        backgroundColor: "lightblue",
        "& fieldset": {
          border: "none"
        }
      }
    }
  })(TextField);

  return <StyledTextField variant="outlined" />;

updated 2:

If you prefer using a custom theme, you can do it like this:

const theme = createTheme({});
theme.overrides = {
    MuiOutlinedInput: {
      root: {
        backgroundColor: 'lightblue',
      },
      notchedOutline: {
        border: "none"
      }
    }
  };

...

<ThemeProvider theme={theme}>
   <TextField variant="outlined" />
</ThemeProvider>

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

using flexbox in react does not automatically resize

I am attempting to create a layout where the screen is split into two sections - one green block taking up 1/4 of the screen and one yellow block taking up 3/4 of the screen using react.js. However, when I tried implementing the code below, both blocks end ...

Tips for resizing the width automatically within a container?

I am facing an issue with a container that contains 3 DIVS: left sidebar, main content, and a right sidebar. I have made the main content responsive by setting the width to width:calc(100% - 400px); (where 400px is the combined width of the sidebars). Howe ...

Creating a sleek horizontal scrolling list with the least amount of rows using tailwindcss

Is there a way to create a 3-row list with horizontal scroll without the unwanted space between items? I've been using tailwindcss and grid to achieve this layout, but I'm encountering issues with spacing: https://i.stack.imgur.com/WeRyQ.png Cu ...

Exploring ways to customize the input color of Material UI TextField when it is disabled [Version: 5.0.8]

I am having trouble changing the border color and text color when an input is disabled. I have tried multiple variations, as seen below: const textFieldStyle = { '& label': { color: darkMode?'#1976d2':'', } ...

Troubleshooting homepage issues post react-scripts update for create react app

After following the instructions on how to upgrade a React project built with create-react-app, I successfully updated react-scripts from v1.1.4 to v3.4.3. However, I encountered an issue on the homepage that I'm struggling to resolve. In my previous ...

Arranging items by their total sum of arrays in React.js

I'm working with data.js where I have stored my JSON information. Here's a snippet: [ { name: 'Adam Doe', city: 'New York', mark: [8,10,10,10] }, { name: 'Catlyn Stronk', ...

align items center with respect to my central element

Describing my issue might be a bit complex, but I'll give it a shot. I'm working on a website and have 3 div elements in the header for my navigation bar (burger menu / logo / social networks). I've used flex display with justify-content: be ...

Ensure that the div is styled with a white background and positioned next to another div with a right margin

I have a white-colored div that needs to be positioned next to another element on a webpage. Additionally, I need a paragraph placed on top of this div for information purposes. Please refer to the following link to see what I am trying to achieve: body ...

An error occurred due to an unexpected identifier, '_classCallCheck', while the import call was expecting exactly one

Encountering an unexpected identifier '_classCallCheck'. Import call requires precisely one argument. Having trouble with React Native. I have attempted every solution found on the internet, but none proved successful. Is there any way to upgrade ...

A guide on displaying multiple XML files within a JHipster React Application

I'm working with a large collection of XML files (approximately 100 files) that I need to display within a React application, complete with navigation and styling. These XMLs may contain links to other XML files for navigation purposes, as well as ref ...

Encountering a 404 error with Symfony and React Router integration

Whenever I try to refresh the site on routes other than "/" I encounter a 404 error. My setup involves Symfony and React Router. I have tried adding priority to the route, but unfortunately, it doesn't seem to resolve the issue. The code snippet be ...

Changing the style of Vuetify v-list-item when hovering over it

I just started using Vuetify and I came across a v-list sample that I need help with. Here is the link to the Vuetify v-list sample on Github. My v-list: Code: <template> <v-card max-width="500" class="mx-auto" > <v-toolba ...

Having issues changing image types with onError in react functionality

I am facing an issue trying to display images from our project server as they are saved in four different types (jpg, jpeg, png, and gif) and I do not know which type each image will be. To handle this uncertainty, I wrote the following code within my img ...

Navbar optimization by eliminating unnecessary whitespace at the end

I'm working on a navigation bar that has four links. I need to get rid of the extra space to the left of "Projects" and to the right of "Contact." It seems like this spacing is part of the unordered list structure, rather than padding or margin. Chec ...

"Implementing a dynamic way to assign values to different item types in React

There is an object with multiple values inside: const [sort, setSort] = useState({ "city": [], "price": [], "year": [] }); When the "add" button is clicked, the "city" value should be updated to include certain va ...

:after functionality not operating properly in Internet Explorer

The titles on this page have arrows displayed before them using a special styling. However, there seems to be an issue with how it displays on Internet Explorer. // edit : I made a mistake, my styling is actually on paragraph tags 'p'. Maybe tha ...

Adding HTML components to an image with adjustable dimensions

A graphic designer has provided us with an image featuring three selection boxes. I implemented the necessary HTML elements and CSS to display three overlapped selection boxes on top of the image, using pixel values for positioning. However, the original ...

Tips for avoiding anti-aliasing of bitmap font on Internet Explorer and Firefox

I am currently experiencing issues with font smoothing when using a basic bitmap font for icons. While the font appears crisp in Chrome, it appears blurry in IE and FF. Do you have any recommendations on how to resolve this problem? You can view a screen ...

Are there any techniques for enabling horizontal scrolling on the MaterialTable to handle overflow?

I am currently utilizing the MaterialTable component from the material-table library. I would like to make the table scrollable on the x-axis to accommodate a large number of columns. Below is the code snippet: <MaterialTable title="Members Acc ...

Exploring the wonders of Next.js and its ability to incorporate

I am currently working on a Next.js (13.3.0) project and facing an issue with global styles that include animations. Here is the structure of my folders: https://i.stack.imgur.com/nM5xw.png All SCSS files are loaded through the master.scss file: @import & ...