Ways to modify the .MuiSelect-nativeInput element within Material-UI

const styles = makeStyles((theme) => ({
  root: { margin: "0px 20px" },
  textStyle: {
    fontFamily: "Comfortaa",
  },
  container: {},
  textField: {
    fontFamily: "Comfortaa",
  },
  dropDownFormSize: {
    width: "100%",
    fontFamily: "Comfortaa",
  },
  optionDropdown: {
    color: "black",
  },
  dropDownSelector: {
    color: "black",
    backgroundColor: "tomato",
  },
  nativeInput: {
    opacity: "1",
  },
}));

const MainTable: React.FC = () => {
  const classes = styles();
  <FormControl
    classes={{
      root: classes.dropDownFormSize,
    }}
  >
    <Select
      required
      className={classes.dropDownSelector}
      value={emotion[i]}
      name="emotion"
      onChange={handleChangeEmotion(i)}
      classes={{
        root: classes.optionDropdown,
        select: classes.optionDropdown,
        // using nativeInput here gives me error
        nativeInput: classes.nativeInput,
      }}
      MenuProps={{
        anchorOrigin: {
          vertical: "bottom",
          horizontal: "left",
        },
        getContentAnchorEl: null,
        MenuListProps: {
          className: classes.optionDropdown,
        },
      }}
      placeholder="Select Something"
      native={false}
    >
      <MenuItem
        value=""
        disabled
        // className={
        //     classes.optionItems
        // }
      >
        Select Emotion
      </MenuItem>
      {emotions.map((emotion, i) => {
        return (
          <MenuItem
            key={i}
            // className={
            //     classes.optionItems
            // }
            value={emotion}
          >
            {emotion}
          </MenuItem>
        );
      })}
    </Select>
  </FormControl>;
};

I am looking to eliminate the opacity from the .MuiSelect-nativeInput Class. When attempting to override this class with the nativeInput rule, I encounter the following error message :-

 Object literal may only specify known properties, and 'nativeInput' does not exist in type 'Partial<ClassNameMap<SelectClassKey>>'.
Despite the fact that the documentation of theSelect API includes the nativeInput rule. I have made attempts to override it in the Theme file but continue to receive an error indicating that nativeInput does not exist. How can I remove the opacity from the MuiSelect-nativeInput class.

https://i.sstatic.net/xt3ZB.png https://i.sstatic.net/4aYJY.png

Answer №1

You have the option to utilize a TextField that is displayed as a select input.

const customStyles = makeStyles({
  main: {
    "& .MuiSelect-nativeInput": {
      opacity: 1,
    },
  },
});

<TextField 
  select
  classes = {{ main: customStyles.main }}
/>

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

What is the process for adding image previews when uploading images in a React application?

I'm grappling with how to enable the uploading of multiple images with a preview in Next.js (React). I've attempted to adjust the constants to arrays and implement mapping through them, but it's proving to be a challenge and I'm unsure ...

The code `$(body).css({'background-image':'url'}) is not functioning properly

Is it safe to assume that the .css() method cannot be applied to the body tag? Since it seems to work fine when used on $("#div")... ...

An ongoing issue with redux-form-material-ui is that when using getRenderedComponent(), it consistently results in

I found inspiration in the official example provided by the creators of the redux-form-material-ui repository. Here is a snippet of my code: import React from 'react'; import { Field } from 'redux-form'; import { TextField } from &apos ...

Ways to update the color of the mat-dialog-title using the material theme

Currently, I am utilizing the Angular Material Dialog and have been attempting to dynamically change the title color of the dialog based on the material theme. <h1 mat-dialog-title color="primary">{{ title }}</h1> Even though setting ...

Swap the text within the curly braces with the div element containing the specified text

I have an input and a textarea. Using Vue, I am currently setting the textarea's text to match what's in the input field. However, now I want to be able to change the color of specific text by typing something like {#123123}text{/#}. At this poin ...

Duplicate multiple "li" elements using jQuery and place them in a designated position within the ul element, rather than at the end

I am currently working on developing a dynamic pagination bar. This pagination bar will dynamically clone the "li" elements based on a number received from an external webservice. Here is the structure of my pagination element: <ul class="pagination"& ...

Animation Effects in Opera and Internet Explorer

Just unveiled my latest project, CSSload.net - an awesome tool for generating CSS spinners and bars. The animations are running smoothly on Firefox and Webkit browsers. Curious if anyone has tips on animating elements like this in Opera and IE? ...

Generate a fresh line within the source code

Currently, I am facing a challenge with dynamically loading CSS, JS, and other components as it appears messy when viewed from the source. Although this issue does not impact functionality, I am not satisfied with how it looks in the source code. When exam ...

Changing the background color of the canvas using Javascript

I want to create a rect on a canvas with a slightly transparent background, but I don't want the drawn rect to have any background. Here is an example of what I'm looking for: https://i.stack.imgur.com/axtcE.png The code I am using is as follo ...

Issue with typescript in Material-UI Next

I encountered an error while trying to integrate material-ui-next component into a default VS2017 react-redux template. The error message reads as follows: ERROR in [at-loader] ./node_modules/material-ui/BottomNavigation/BottomNavigationButton.d.ts:6:74 T ...

Tailwind does not display font sizes using random values

I am attempting to adjust the size of a span element based on a number from a variable: export default async function Tags() { const tags = await getTags(); return ( <div> <Suspense> <div className="flex flex-wrap ...

Could someone please assist me in configuring Autocomplete (MUI) to display my options?

A friend of mine is experiencing difficulty with getting Autocomplete to display anything. Here's the code snippet in question: var names = []; const schoolList = async () => ( await axios.get("http://localhost:5000/api/grabUnivNames/") ...

The use of findDOMNode has been marked as outdated in StrictMode. Specifically, findDOMNode was utilized with an instance of Transition (generated by MUI Backdrop) that is contained

I encountered the following alert: Alert: detectDOMNode is now outdated in StrictMode. detectDOMNode was given an instance of Transition which resides within StrictMode. Instead, attach a ref directly to the element you wish to reference. Get more inform ...

Issue with Bootstrap rows overlapping on smaller screens

Basically, the issue I'm facing is that when I reduce the size of my screen, the columns drop below and start overlapping with the row beneath them. I've been trying to figure out if there's a simple solution that I'm overlooking. But ...

Can you guide me on how to activate the pickadate.js calendar above the input field?

Encountering an issue with the Pickadate calendar. There seems to be a problem at the bottom of the page, please refer to the attachment for more details. My challenge is that I need to display the Pickadate calendar above the input field when the field is ...

Stylishly incorporating components in higher-order components

Trying to enhance my component wrapper with styles using a higher order component has led to Typescript flagging an error with ComponentWithAdddedColors. type Props = { bg?: string; }; function withColors<TProps>( Component: React.ComponentType ...

The React front-end struggles to display MongoDB entries and eventually times out after 10 seconds

I am experiencing an issue where my React front-end is unable to fetch details from a MongoDB database and I need assistance debugging the problem. The back-end utilizes a serverless function. Each time I reload the page, my React code fails to locate the ...

Utilizing external Cascading Style Sheets in AngularJS 1

Can an external CSS be applied to a component in AngularJS1? If yes, then how can it be done? I have only seen examples of applying inline css... ...

The children's className attribute can impact the parent element

As I work on creating a card object, I envision it with the className .card that is styled in CSS as follows: .card img{position:absolute; width:150px; height:160px} I want only the images inside my div to overlap each other while not affecting the divs ...

Incorrect Arrow Direction of Bootstrap Popover on SVG Icon

I set up a bootstrap(v5.1) popover on an svg icon, but the arrow icon direction is incorrect. Check out the code snippet below to see how it's configured; @create text & @modifytext are placeholders for dynamic content. <svg height="20& ...