To add the icon to mat button text we need to add mat icon before the text of button as shown below h3 mat button with icon and text h3 button mat raised button color primary mat icon shopping cart mat icon add to cart button.
Mat icon button with text.
We have to import maticonmodule from angular material modules.
I created the additional style to avoid breaking angular material components that are using mat icon and expecting it to be of default size and default alignment.
For buttons with both icons and text use the mdc button component.
Ui component infrastructure and material design components for mobile and desktop angular web applications.
Icon buttons allow users to take actions and make choices with a single tap.
Eventcallback mouseeventargs event occurs when.
When all is said and done there is a solid and simple recipe for getting icons exactly where you want to line up with text icon position.
For example mat icon home mat icon displays home icon.
If a text label is not used an icon should be present to signify what the button does.
Button has dense style.
Force browser to redirect outside component router space.
Text buttons and contained buttons use text labels which describe the action that will occur if a user taps a button.
Link to a url when clicked.
Import maticonmodule from angular material icon.
By default material uses capitalized button text labels for languages that have capitalization.
For more information see the mdc button docs.
The approach above worked acceptably fine with different font sizes of the text around the icon the icon is always vertically centered if that s what you want.
Install with bower install with npm view source on github doc humanizedoc directivebrackets doc restrict doc humanizedoc directivebrackets view demo view source on github.
Adjust these values accordingly top.
Text label of button.