3

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?

2
  • You should be able to use it on its own. What exactly are you asking? Commented Oct 31, 2020 at 18:51
  • @Edric Right, but I want it to be styled nicely, it should look like a button. Commented Nov 1, 2020 at 1:48

1 Answer 1

6

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

  1. insert the select in a button component.
  2. position and size the select to cover the button.
  3. make the select opacity 0 so it's not seen.
  4. call the open() method on button click.
Sign up to request clarification or add additional context in comments.

2 Comments

Do yourself a favor and just use the mat-menu
@Zen if you want to allow the user to select multiple options, it's more straightforward to use mat-select since this component natively supports that feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.