Tips for customizing the appearance of Angular Material's autocomplete feature

Currently, I am working with Angular and implementing Angular Material components like md-autocomplete from [https://material.angular.io/components/autocomplete/api][1]. However, I am facing an issue trying to add a border radius to my md-autocomplete element as shown below:

<md-autocomplete  class="myclass">

.myclass{
    background-color: rgb(250, 250, 250);
     border-bottom-left-radius: 50px;
     border-bottom-right-radius: 50px
}

Can anyone provide insight into why this is not working?

Answer №1

If you want to customize the look of a dropdown list, simply use the .mat-autocomplete-panel class:

::ng-deep .mat-autocomplete-panel{
  border-radius: 10px;    
}

This style change will be applied to all autocomplete lists. However, if you have multiple autocompletes and want to style them differently, you can assign unique variable names and style them accordingly. For instance, for the second autocomplete:

HTML

<md-autocomplete #mauto="mdAutocomplete">

CSS

::ng-deep .mat-autocomplete-panel#md-autocomplete-0{  //for the first one

::ng-deep .mat-autocomplete-panel#md-autocomplete-1{ //for the second one

Check out the demo here.

Answer №2

Are you looking to add a border around the md-autocomplete element or do you prefer to have the border surrounding the md-form-field instead?

Based on my understanding, I believe you would like the border around the form field. You can refer to https://material.angular.io/components/autocomplete/examples for an example of the HTML code.

To see how your CSS can style the md-form-field, take a look at this Plunker:

.example-full-width {
     background-color: rgb(255, 0, 0);
     border-bottom-left-radius: 50px;
     border-bottom-right-radius: 50px
}

Check out the Plunker here: https://plnkr.co/edit/DWzjsRNGXZsPRfjWRrI6?p=preview

I opted for red color in place of the 15% gray so that it stands out more prominently.

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 method can we use to verify if an object falls within a specified date range when filtering?

Looking to determine if the current filter object falls within a specific date range and return a boolean value based on that condition. However, the code provided always returns the data. Can anyone spot the error in the implementation or suggest a better ...

Technique for seamlessly moving between subpages and main page while scrolling to a specific id

I'm struggling with coding and thought I'd reach out for help here. Can anyone provide a solution to my problem? Issue - I have a navigation link on my main page that scrolls to an ID using jQuery. It works fine on the main page, but not on any ...

Change the color of the icon from white to blue in png format using html/css

Changing a White Icon.png to a Blue Icon.png Using HTML/CSS The original icon.png is white in color. How can we change it to a blue color version using only HTML and CSS? HTML: <img src="icon.png" class="icon1"> CSS: .icon1 { background: url(ic ...

How to disable click event binding in Angular2 after it has been clicked once

Within my application, there is a button that has a click event attached to it: <button class="btn btn-default" (click)="doSomething()"> I am wondering if there is a way to remove the (click) event from the button within the doSomething method so t ...

Asymmetrical Edges for a Pair of Divisions

Is there a way to skew two divs without a white line in between, similar to this example: Desired outcome I have tried using a negative top margin, but it doesn't work well in responsive design. Current result Here is the code I am using: ... < ...

What is the best way to switch the background color of a dropdown div when hovering over it?

I've been working on getting the color to fill the entire dropdown area based on the text you're hovering over, but it's only filling the space around the word. I've set up a Fiddle to demonstrate the issue I'm facing. I'm ne ...

The Bootstrap grid is not aligning to the center when dynamically adjusting sizes

I am currently in the process of developing a store website using bootstrap. One issue I am facing involves creating a grid for my product display. The problem is that the number of grid cells remains constant even when the screen size is reduced. I would ...

Positioning the Angular material menu items in the UI

Hey there! I'm looking to create a mat-menu that opens to the left. I found some code snippets on StackBlitz, check it out: https://stackblitz.com/edit/angular-material-menu-position-aside-6ab669?file=src/app/menu-overview-example.html The menu str ...

Automatically change div background image based on window resizing

.step-1-4 { background:url('../images/gadget-4-sprite.png') no-repeat; width:950px; height:70px; margin-left: 15px; } The code above sets the CSS for a div containing a background image. The dimensions of the div match that of the imag ...

Create a sleek and functional navigation bar for your Angular 4 project by incorporating the latest features

After reviewing the ng-bootstrap documentation, I came across a crucial point: Should I add bootstrap.js or bootstrap.min.js to my project? According to ng-bootstrap, it is recommended not to include any JavaScript files such as bootstrap.js or bootstrap. ...

"Enhance User Experience: Use CSS to highlight text selection based on

As a beginner in the world of css and html, I am eager to create a webpage that showcases a list of names with the ability to select one or multiple names. Instead of simply checking a box on the side, I would love for the background of the selected text t ...

Difficulty reloading after updating input using AngularJS ngTable

I'm encountering an issue where I need to utilize ngTable with TableParams to load and modify a table. For instance, when the page initializes, entering a number in the textbox for the first time displays the appropriate number of rows in the table. ...

Choose the initial drop-down option and concentrate on it

How can I target the first drop down node (select element)? I have tried using this code to focus on the first input, but I am looking for a way to target the first select (drop down). $('.modal :input:first').focus(); Unfortunately, this meth ...

"Modifying the content:url() with JavaScript: A step-by-step guide

Hello, I am currently working on creating a traffic light using an array of images. My goal is to change the image path specified in the CSS when a button is clicked, to change the appearance of the traffic light. In this case, the 'content.url()&apos ...

Create a list item that includes an image with a corresponding label positioned beneath it

Currently attempting to convert my design into HTML and CSS for the first time, I've hit a roadblock with this particular task: I'm trying to create a series of white boxes, with each item having a white border. However, I'm struggling to c ...

Tips for displaying data by using the append() function when the page is scrolled to the bottom

How can I use the append() function to display data when scrolling to the bottom of the page? Initially, when you load the page index.php, it will display 88888 and more br tags When you scroll to the bottom of the page, I want to show 88888 and more br ...

Is there a way to modify Font Awesome icon and text based on a specific condition?

component.html <i [title]="CardData.quantity > 1 || _ShippingVariable > 1 ? CannotShip : FreeShipping" [ngClass]="{'fa': true,'fa-youtube': socialMediaLink.socialMediaType === 'YOUTUBE',}"> ...

Struggling to get the bindings to work in my Angular 2 single-page application template project

I have recently started using the latest SPA template within Visual Studio 2017: https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp.net-core-with-javascriptservices/ The template project is functioning properly. ...

Ionic Angular encountered an unexpected 'ERROR' without any detailed explanation or logging

https://i.sstatic.net/aJPD1.png Hey there, I'm encountering some issues with my Ionic App. Currently, I am executing ionic cordova run android --livereload --consolelogs --serverlogs using a physical device. Although I can see console.logs, there ...

It appears that you are not relying on "@angular/core"

Whenever I attempt to construct my project using the following command: ng build --environment=prod --aot=false --output-path="..." --base-href="..." It appears that there is a lack of dependency on @angular/core. This error is puzzling as it used to w ...