feat(mat-button): add progress-spinner option
See original GitHub issueBug, feature request, or proposal:
Proposal
What is the expected behavior?
Allow for a properly-sized and positioned progress spinner to be triggered inside a mat-button
, temporarily overriding its initial content
What is the current behavior?
No configuration available, can manually place and position a progress spinner inside a mat-button
What are the steps to reproduce?
This is a sample template thrown together (very unoptimized): https://stackblitz.com/edit/angular-material2-issue-qbjrmi?file=app%2Fapp.component.html
Click on LOADING
to trigger the spinner
What is the use-case or motivation for changing an existing behavior?
Defined in the spec: https://material.io/design/components/progress-indicators.html#circular-progress-indicators under “Integrating with actions”
Is there anything else we should know?
Probably needs an a11y review since the content of the button will change
Issue Analytics
- State:
- Created 5 years ago
- Reactions:18
- Comments:12 (8 by maintainers)
Top Results From Across the Web
feat(mat-button): add progress-spinner option #13667 - GitHub
We create a new container component called mat-progress-container that doesn't render on the page, but can be triggered and injected into ...
Read more >How to add a loading spinner to an Angular Material button
Here's the 2-minute guide that will show you how to add a loading spinner to the Angular Material Button. Code and explanation included....
Read more >How to add a loading spinner to an Angular Material button
Click here for a 2 minute complete guide to adding a loading spinner to the Angular Material Button. Code and explanation included.
Read more >Progress spinner | Angular Material
Progress mode The progress-spinner supports two modes, "determinate" and "indeterminate". The <mat-spinner> component is an alias for <mat-progress-spinner ...
Read more >@angular/material | Yarn - Package Manager
mat-autocomplete; mat-button; mat-fab; mat-icon-button; mat-card ... ca1aaae7e2, feat, progress-spinner: add color to default options (#24356).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Discussed with @crisbeto offline, and we’ve come up with two options:
mat-progress-container
, but its purpose is to center content inside another container element likemat-button
ormat-menu
matProgress
directive that sits on the container (ie themat-button
ormat-menu
) to setposition: relative
and necessary ARIA attributes based on a boolean triggerHere’s where the ideas diverge:
This not only provides a clear differentiation between the progress and the content, it also reduces the redundancy and possibility for failure by removing the dual
trigger
uses. Here, theprogress-container
is responsible for marshaling content inside the button/menu, replacing the content based on the value of the host’s progress directive.The only issues with both approaches are a) the best way to handle a11y, and b) the best way to swap content while maintaining size concerns (i.e. making sure the container height stays the same)
How come this is still not implemented? Is is specifically stated in the Material Design guidelines that you should “Use circular indicators for short, indeterminate activities (< 5 seconds) requiring user attention.” (https://material.io/components/progress-indicators#circular-progress-indicators) - i.e. anything that requires a trip to the server when clicking the button. If this library is supposed to follow the Material Design guidelines, this feature needs to be implemented. I know you can do it manually, but this really is something that I would expect a library like Angular Material to just take care of. Of the proposed APIs by @CaerusKaru, I’d definitely prefer option 2. I don’t think you should have to manually do *ngIf and templates to make this feature work.