Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buttons with an icon and text are not up to spec #15798

Open
calebegg opened this issue Apr 11, 2019 · 3 comments
Open

Buttons with an icon and text are not up to spec #15798

calebegg opened this issue Apr 11, 2019 · 3 comments
Labels
area: material/button area: material/icon P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@calebegg
Copy link
Member

The icon needs to be 18x18 and have 8px of space to the right of it, per:

https://material.io/design/components/buttons.html#specs

Here's what I used:

.mat-button-wrapper .mat-icon {
  height: 18px;
  width: 18px;
  line-height: 18px;
  margin-right: 8px;
}
@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Apr 12, 2019
@marvinderksen
Copy link

marvinderksen commented May 3, 2019

In addition to that we need to reduce the button's left padding to 12px (e.g. by applying a left margin of -3px to the icon).
Should the font size of the icon be reduced to 18px?

@arlowhite
Copy link

I was going to create a separate issue for this, but this one seems related.

MatButton with icon & text is not documented on https://material.angular.io/components/button/overview

It's not clear whether developers should use a <span> around the label text or not and this choice affects the spacing between icon & text. I realize this is an artifact of how HTML works, but it should be documented or corrected by Material CSS.

Spacing Reduced:
In these cases, HTML does not render a space between icon & text.

<button mat-raised-button>
  <mat-icon>favorite</mat-icon>
  <span>Favorite</span>
</button>
<button mat-raised-button>
  <mat-icon>favorite</mat-icon>Favorite
</button>

Space between icon & text:
In these cases, HTML renders the space, which creates spacing between icon & text

<button mat-raised-button>
  <mat-icon>favorite</mat-icon>
  Favorite
</button>
<button mat-raised-button>
  <mat-icon>favorite</mat-icon>
  <span> Favorite</span>
</button>

@meta72
Copy link

meta72 commented Jan 9, 2020

@calebegg I used your workaround but had to exclude mat-fab, mat-mini-fab and mat-icon-button.

:not(.mat-fab):not(.mat-mini-fab):not(.mat-icon-button) > .mat-button-wrapper .mat-icon,
:not([mat-fab]):not([mat-mini-fab]):not([mat-icon-button]) > .mat-button-wrapper .mat-icon {
	height: 18px;
	width: 18px;
	line-height: 18px;
	margin-right: 8px;
	margin-left: -4px;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/button area: material/icon P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

5 participants