I would like to use the angular material mat-select component without the mat-form-field, I want it to be conceptually similar to the native select element. Is there a way to achieve that?
-
You should be able to use it on its own. What exactly are you asking?Edric– Edric2020-10-31 18:51:06 +00:00Commented Oct 31, 2020 at 18:51
-
@Edric Right, but I want it to be styled nicely, it should look like a button.meblum– meblum2020-11-01 01:48:11 +00:00Commented Nov 1, 2020 at 1:48
Add a comment
|
1 Answer
A simple approach is to use a mat-menu and update the trigger on button-click.
demo using mat-menu component.
If you don't want to use a menu but a mat-select, here is a solution which uses the select component and also ensures the panel is positioned properly when opened:
demo using mat-select component
- insert the
selectin abuttoncomponent. - position and size the select to cover the button.
- make the
selectopacity 0 so it's not seen. - call the
open()method on buttonclick.