What are the ways to personalize the material UI select component?

I am looking to customize a MUI select component that I have rendered on a dark background. My goal is to make the outline and all its contents light colors, specifically grey and white.

https://i.sstatic.net/HFUBj.png

So far, I have successfully changed the outline and text contents to light colors. However, I am struggling to figure out how to adjust the colors of the down and up arrows that are clicked on to open and close the select options. If you refer to the screenshot I provided, you'll notice that the up arrow is barely visible because it's black. How can I modify the color of the arrow to be grey or white?

This is my current setup:

<Select
    variant="outlined"
    sx={{
    width: 100,
    height: 40,
    marginRight: 15,
    border: "1px solid darkgrey",
    color: "#fff",
    }}
    value={currency}
    onChange={(e) => setCurrency(e.target.value)}
>
    <MenuItem value={"USD"}>USD</MenuItem>
    <MenuItem value={"INR"}>INR</MenuItem>
</Select>

Answer №1

I successfully modified the arrow icon's color by following these steps.

<Select
    variant="outlined"
    sx={{
    width: 100,
    height: 40,
    marginRight: 15,
    border: "1px solid darkgrey",
    color: "#fff",
    "& .MuiSvgIcon-root": {
        color: "white",
    },
    }}
    value={currency}
    onChange={(e) => setCurrency(e.target.value)}
>
    <MenuItem value={"USD"}>USD</MenuItem>
    <MenuItem value={"INR"}>INR</MenuItem>
</Select>

Answer №2

If you want to add an icon to your select input, you can utilize the icon css class from the select component (or use iconOutlined in your specific scenario).

One way to achieve this is with the help of makeStyle.
Note that this method is outdated for material-ui 5, refer to the comment section and the alternative answer below.

// Define useStyles outside the component
const useStyles = makeStyles(() =>
  createStyles({
    iconClassName: {
      fill: "red",
    },
  })
);

...

// Apply styles inside the component
const classes = useStyles();

<Select 
  classes={{ iconOutlined: classes.iconClassName }}
/>

Alternatively, you can replace the default icon by using the IconComponent props:

<Select 
  IconComponent={<YourComponentHere />}
/>

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'm curious if it's possible to superimpose a png image and specific coordinates onto a map by utilizing react-map

I am attempting to showcase a png graphic on a react-map-gl map, following the approach outlined here. Unfortunately, the image is not appearing as expected and no error messages are being generated for me to troubleshoot. Below is the snippet of code I&a ...

The drop-down links vanish into the depths of the webpage's body

Can someone assist with my drop-down menu issue for the link "services"? The link disappears behind the page content when I try to modify it. Any help would be appreciated, thank you! This is the CSS: .bodycontent { margin: 0 25% 0 25%; ...

Tips for sending props to MUI styled menu for creating specific conditional styling effects

Is it possible to pass props to an already styled Material-UI menu with conditional styling for different minimum widths? The issue I am facing is that the menu's styles are outside of the component receiving the props, so how can I achieve this? c ...

The CSS syntax definition for list styles

Inside the body of my site is this code: Here is the HTML: <ul id="navlist"> <li class="first"> <a href="/" id="current">Home</a> </li> <li> <a href="/Store/">Store</a> </ ...

Node.js Email Registration Confirmation Process

Creating an app using nextJS has been a great experience for me. I have successfully implemented functionality that requires users to register by entering their username (email address) and password on the registration page. Upon submission, this data is ...

How to perfectly position various height <a> elements in a WordPress mega menu

I'm currently working on a WordPress mega menu with four columns, each with a heading or top menu item. The headings should have a gradient border at the bottom and differ in length. However, I'm facing an issue where some headings span two lines ...

The background color for filled text fields is not functioning properly in Swift Material Components

Here is the code snippet I used in attempt to change the background color of a filled text field, but unfortunately it did not work as intended: import MaterialComponents ... @IBOutlet weak var textfield: MDCFilledTextField! let scheme = MDCContainerSc ...

Guide on maintaining focus within nested components in React

Within my React chat app, I have a structure of components organized as follows: ThreadList Thread Reply ReplyMenu ReplyButton <button onClick="?" /> Reply Reply . ...

Using javascript to color in cells of a grid of "pixels"

I have a project similar to an Etch-a-Sketch in progress. The main challenge I am currently facing is how to gradually darken each cell of the grid with every pass of the mouse cursor, based on the opacity of the cell being hovered over. When the grid cell ...

Is it possible to replace text on click using CSS instead of jQuery?

My new project involves creating a flashcard system. The idea is that when a question is clicked, it reveals the answer and hides the question. To achieve this, I am currently using the following code: jsFiddle <p id="shown">What is stackoverflow?&l ...

Positioning the footer to sit at the bottom of my webpage, leaving a pleasing margin at the top

One technique I frequently use to ensure my footer stays at the bottom of my page is by utilizing an empty div. Here's how the code looks: <body> <div id="canevas"> <article>My website's content</article> ...

evt.target consistently returns the initial input within the list of inputs

My React file uploader allows users to attach multiple file attachments. Each time a user clicks on an input, I retrieve the data-index to identify the input position. renderFileUploader() { let file_attachment = this.state.file_attachment.map(fun ...

Upon mounting, Jest and Enzyme are unable to find the function document.createRange

While attempting to utilize the enzyme mount function on a component that incorporates MaterialUI's Tooltip, I encountered an issue halting my tests: TypeError: document.createRange is not a function ...

The outputstring encountered an issue with the HTML class

Struggling a bit with php, I'm trying to incorporate a basic comment system that accesses and writes to a comments.php file. Everything is functioning well until I attempt to style the $outputstring. Here's the code in question: $outputstring ...

Guide on incorporating `Animate.css` into an Angular application

I've been attempting to implement the bounceInUp animation from animate.css on a div upon showing it, but I can't seem to get it to work. What am I doing wrong? Can someone guide me on the correct way to achieve this effect? This is my CSS code ...

Is it possible to execute an onClick event and a <NavLink to="/Scooters"> simultaneously?

Is it feasible in React to both filter my database and redirect to another route upon clicking the search button? I am currently employing <BrowserRouter>. It would also be advantageous if this redirection could occur directly from the onClick even ...

After deploying on Heroku, the Mongodb, Reactjs, Express, and Node.js project is showing a blank page and experiencing 404 errors

My app is functioning locally, with routes working via Postman and the database being accessed in Robo 3t. However, when deployed on Heroku, the app only displays a blank page upon launch. The console shows the following error: image description Here is t ...

Display data from two arrays in real-time

The following data is available: "PensionPlanSummary": [ { "Type": "DefinedContributionPension", "Participants": [ { "Year": 2018, "Value": 425.0 } ...

What is the best way to vertically align my image for perfect centering?

On one of my pages at , there is a section titled "FREE PICK UP AND RECYCLING OF LARGE QUANTITIES OF ELECTRONICS" with a picture of a truck. The image is perfectly centered vertically between the pictures on its left and right. Another page I have at fea ...

Large button in Bootstrap 3 breaks out of Jumbotron on smaller mobile screens

I have set up my layout with a Jumbotron that features a prominent call-to-action button. <a href="#" class="btn btn-lg btn-success">Let's Purchase Something Elegant</a> However, when viewed on an XS mobile screen, the button extends bey ...