Skip to content

bug(mat-card): buttons in mat-card-actions do not consider its align attribute #20024

Closed
@karmasakshi

Description

@karmasakshi

Reproduction

StackBlitz: https://stackblitz.com/edit/components-issue-ampt5f?file=src%2Fapp%2Fexample-component.css

Steps to reproduce:

  1. Add a card with 2 or more buttons in mat-card-actions
  2. Inspect space between them

Actual behavior

Screenshot 2020-07-17 at 5 40 57 PM

Expected behavior

Screenshot 2020-07-17 at 5 41 45 PM

Proposed fix

Based on align=start or align=end, the first or the last button should be applied the style which is right now applied to the first button regardless:

Screenshot 2020-07-17 at 5 39 30 PM

This can be solved by the following snippet:

.mat-card-actions .mat-button,
.mat-card-actions .mat-raised-button,
.mat-card-actions .mat-stroked-button {
  margin: 0 8px !important;
}

.mat-card-actions[align="end"] .mat-button:last-child,
.mat-card-actions[align="end"] .mat-raised-button:last-child,
.mat-card-actions[align="end"] .mat-stroked-button:last-child {
  margin: 0 !important;
}

.mat-card-actions[align="start"] .mat-button:first-child,
.mat-card-actions[align="start"] .mat-raised-button:first-child,
.mat-card-actions[align="start"] .mat-stroked-button:first-child {
  margin: 0 !important;
}

Similar/related issues I found:

#18391
#13382

Environment

  • Angular: 10
  • CDK/Material: 10
  • Browser(s): Safari, Chrome, Firefox latest
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/card

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions