Tips on customizing the color of the arrow in an mdc-select dropdown menu?

I'm struggling to modify the default purple color of the dropdown arrow in an mdc-select:

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

None of the sass mixins seem to be effective in making the change.

Any suggestions on how this can be achieved?

Here are my attempts so far:

HTML

<div class="mdc-select mdc-select--outlined">
    <input type="hidden" name="enhanced-select">
    <i class="mdc-select__dropdown-icon"></i>
    <div class="mdc-select__selected-text" class="mdc-select__selected-text" role="button" aria-haspopup="listbox" aria-labelledby="demo-label"></div>
    <div class="mdc-select__menu mdc-menu mdc-menu-surface">
        <ul class="mdc-list">
            <li class="mdc-list-item" data-value="41" role="option">41</li>
            <li class="mdc-list-item" data-value="42" role="option">42</li>
            <li class="mdc-list-item" data-value="43" role="option">43</li>
        </ul>
    </div>
    <div class="mdc-notched-outline">
        <div class="mdc-notched-outline__leading"></div>
        <div class="mdc-notched-outline__notch">
            <label class="mdc-floating-label">Answer to Life</label>
        </div>
        <div class="mdc-notched-outline__trailing"></div>
    </div>
</div>  

SCSS

@import "@material/list/mdc-list";
@import "@material/menu-surface/mdc-menu-surface";
@import "@material/menu/mdc-menu";
@import "@material/select/mdc-select";

.mdc-select {
    @include mdc-select-ink-color(green);
    // @include mdc-select-container-fill-color(green);
    @include mdc-select-label-color(green);
    @include mdc-select-focused-label-color(green);
    @include mdc-select-bottom-line-color(green);
    @include mdc-select-focused-bottom-line-color(green);
    @include mdc-select-hover-bottom-line-color(green);
    @include mdc-select-outline-color(green);
    @include mdc-select-focused-outline-color(green);
    @include mdc-select-hover-outline-color(green);
    @include mdc-select-icon-color(green);
}

TS

import { MDCSelect } from '@material/select';
const select = new MDCSelect(document.querySelector('.mdc-select'));

Answer №1

This arrow is not an icon or a font; it is actually a background image of the

.mdc-select--focused .mdc-select__dropdown-icon
class. To change the color of the image, you can use the filter CSS property.

filter: hue-rotate(60deg);

Simply apply this CSS code to your custom stylesheet for the

.mdc-select--focused .mdc-select__dropdown-icon
class and it will take effect.

Thank you.

Answer №2

To style it according to my preferences, I utilized a special MDC internal Sass mixin called mdc-select-dd-arrow-svg-bg_. Here's an illustration:

.mdc-select .mdc-select__dropdown-icon {
    @include mdc-select-dd-arrow-svg-bg_(COLOR, 1);
}

In this context, the value of COLOR can either be one of the predefined MDC theme properties (such as 'secondary') or any valid HTML color code (for instance, #ff0000). It is important to note that it cannot be defined as a variable because, as highlighted by @KuldipKoradia, an SVG image is generated during compilation process.

Answer №3

A simple solution is to hide the SVG and customize your own dropdown arrow using CSS without any need for HTML modifications. This allows you to easily update the color whenever necessary:

.custom-select__dropdown-icon{
  background: none;
  width: 0;
  height: 0;
  bottom: 24px;
  right: 10px;  
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #333333;
}
.custom-select--activated .custom-select__dropdown-icon,
.custom-select--focused .custom-select__dropdown-icon {
  border-top: 5px solid #FF0000;
}

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

Any ideas on how to align the links in the navbar at the center of the image instead of having them at the top?

<!DOCTYPE html> <html> <head> <title>Funky Munky Arcade</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha ...

The Angular Compiler was identified, however it turned out to be an incorrect class instance

Although this question has been asked before, I have exhausted all possible solutions that were suggested. Unfortunately, I still cannot resolve it on my own. Any assistance would be greatly appreciated. Error: ERROR in ./src/main.ts Module build failed: ...

Inserting lines into the text, creating a visually appealing layout

Can a notepad design be created using CSS only? Is it feasible to include lines between text lines without using underscores? I want it to look like this example but with minimal spacing between lines and no manual insertion of span tags since the text wi ...

Adjust the height of the box based on the content within its flexbox

I have a flexbox div nested inside another div, and I'm trying to adjust the height of the outer box based on the content of the inner flexbox. Here is the link to the current fiddle. The issue I am facing is that the text in the second box overflows ...

Utilizing Angular's directive-based *ngIf syntax instead of passing a string parameter

Currently, I'm studying the article on reactive forms by PluralSight to brush up on my knowledge and I'm having trouble understanding the syntax provided below. <div *ngIf courseForm.get('courseName').valid && courseForm.get ...

Having trouble retrieving information from an asp.net core API in Angular 6

My current project involves a backend .NET Core API and an Angular 6 frontend. I am using the datatables plugin to display data in a grid, but even though the data is being passed from the API, it is not showing up in the grid; the grid appears blank. Bel ...

Having trouble bringing in icons from the @mui/icons-material library

An error occurs when attempting to run the code. wait - compiling... error - ../../../../../node_modules/@mui/icons-material/esm/utils/createSvgIcon.js:1:0 Module not found: Can't resolve '@mui/material/utils' null Note: @mui/material pack ...

adjusting array based on screen size fluctuations

Imagine having two arrays of images named landscape_images[] and portrait_images[]. One is for the landscape view and the other for the portrait view. When the screen width is in landscape mode, the wide resolution images will be displayed on the body. C ...

Can we retrieve the CSS of an element?

Using Selenium's webdriverJS, I have automated tasks on an HTML5 page. To incorporate a CSS selector into a function, I had to rely on XPath for selecting elements: var complexXpath = "//*/div/a"; /* This is just an example */ var element = mydri ...

Loading Website Content, Track your Progress

I'm facing an issue with the website loading progress bar. The script I'm using for the progress bar is not functioning correctly on the Web server www.example.com. Even though the website is live on the web server, the problem is that the progre ...

Issue with Bootstrap 5.2 carousel not toggling the visually-hidden class

The hitboxes of the previous and next buttons are visually hidden. Additionally, the indicators at the bottom appear strange, and the sliding animation is not as smooth as expected. Despite searching extensively and trying various solutions, I am still un ...

Preventing duplicate values within an array

Currently, I am working on a rather challenging task that is pushing the limits of my brain. The project involves managing data with a 'position' field, which determines the order they are displayed on the client side. Users can adjust the positi ...

How to center a Bootstrap 4 navbar with brand and links in the middle

I'm facing some difficulty in centering the navigation bar of my website, including the brand and the links. Since I am more focused on backend development, I'm struggling with the frontend aspect of this. Code <script src="https://ajax.go ...

What could be causing the font of the background text to change when CSS3 animation is applied?

Have you ever noticed a font style change in the background text when applying CSS3 animations for opacity and scale transforms? I have some text content on my page, including a "Click me" link that triggers a popup with a CSS3 animation. However, I'v ...

Is there a way to reorganize the layout of a container on mobile using this code?

Is it possible to rearrange this code for mobile view? Currently, on desktop, the <div class="grid4-12"> (left) and <div class="grid8-12"> (right) are stacked on top of each other. How can I adjust the code so that on a r ...

Unable to interact with menu in Internet Explorer

I am facing an issue with my code that should create a dropdown menu when hovered on, but it is not working properly in Internet Explorer. Instead of dropping down the menu, IE pushes it to the right, making it impossible to interact with. Surprisingly, th ...

Issue with hiding the overflow of the document's body

Despite finding a solution to a previous issue on Stack Overflow, I am now facing a new challenge. Adding margin:0em auto; to my page is causing it to have a 'jumpy' effect. .align-center-public { width:1000px; margin:0em auto; overf ...

Connect your Angular2 app to the global node modules folder using this link

Is there a way to set up a centralized Node modules folder on the C disk instead of having it locally within the app directory? This would be more convenient as Angular2 CLI tends to install over 125mb of Node modules in the local folder. In our TypeScrip ...

What is the best way to line up changing column values with changing row values in an HTML table?

In its current state, the data appears as follows without alignment: https://i.sstatic.net/o5OLu.jpg The data columns are housed within a single variable due to the presence of multiple excel tabs with varying columns. Within the tr tag, rows are checked ...

What can I do to prevent the border from breaking apart when I zoom in?

To address the problem of the 1px black border at the bottom of the header being cut off, try zooming into the page and scrolling right. How can this issue be resolved? ...