question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple mat-icon or mat-icon-button as prefix or suffix are displayed in columns

See original GitHub issue

Bug:

More than one mat-icon or mat-icon-button as prefix or suffix in a mat-form-field are displayed in columns when appearance is other than ‘legacy’.

What is the expected behavior?

They should display in row like in ‘legacy’ appearance.

What is the current behavior?

They are displayed in column.

What are the steps to reproduce?

https://stackblitz.com/edit/material-multiple-presuffix

What is the use-case or motivation for changing an existing behavior?

Behavior is not consistent accros mat-form-field appearances.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/material 7.1.0

All browsers.

Is there anything else we should know?

I see 2 solutions : Solution 1 : Remove this two rules :

:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-prefix .mat-icon,
:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-suffix .mat-icon {
    display: block;
}
:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-prefix .mat-icon-button,
:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-suffix .mat-icon-button {
    display: block;
}

Solution 2 : Use flexbox for prefix and suffix :

.mat-form-field-prefix,
.mat-form-field-suffix {
  display: inline-flex;
  align-items: center;
}

Potentially related issues : #11650, #13094, #13322 & #13592

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:21
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
mmalerbacommented, Nov 6, 2020

as a workaround for this, use a single matSuffix div and arrange the items inside however you like: https://stackblitz.com/edit/material-multiple-presuffix-u7kax5?file=app%2Fform-field-prefix-suffix-example.html

0reactions
am-castrocommented, Nov 28, 2022

Hi! in newest versions of material angular use this:

anywhere css

::ng-deep .mat-form-field-prefix,
.mat-form-field-suffix {
  display: inline-flex;
  align-items: center;
}

or add in style.css:

.mat-form-field-prefix,
.mat-form-field-suffix {
  display: inline-flex;
  align-items: center;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material: Weird suffix fucntionality - Stack Overflow
I am using angular material's form field component to create my forms... I noticed that if I use a button inside the mat...
Read more >
Form field with prefix & suffix - StackBlitz
Form field with prefix & suffix. ... <button mat-icon-button matSuffix (click). ="hide = !hide" [attr.aria-label]="'Hide.
Read more >
Angular Material: table - Rob Ferguson
A sample (column definitions) JSON configuration file: ... *matHeaderCellDef class="header-cell-id"> <button mat-icon-button> <mat-icon ...
Read more >
Angular Material (MAT) Form-Field - Javatpoint
The <mat-form-field> is a component that is used to wrap multiple MAT components and implement common text field styles of the form-field such...
Read more >
Changelog - Oblique
button: ensure links without href are displayed correctly (fbf8cd0) ... material: ensures Oblique style for mat-icon-button only applies to Oblique buttons ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found