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.

<mat-dialog-actions>: Button spacing does not match MD spec

See original GitHub issue

Bug, feature request, or proposal:

Buttons that are inside mat-dialog-actions currently have no padding/margin to the left or right. There should be padding between buttons as described in the Material Design spec. Buttons inside mat-card-actions do have a margin left and right of 4px, providing some sort of spacing.

What is the expected behavior?

See Material Design dialogs specs: https://material.io/guidelines/components/dialogs.html#dialogs-specs

What is the current behavior?

See screenshot below taken from the Angular Material example site.

codeexample-md-dialog-mdbuttons)

What are the steps to reproduce?

Visit the Angular Material example site: https://material.angular.io/components/component/dialog

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

Match Material Design spec.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
arlowhitecommented, Apr 26, 2017

This is what I do in my SCSS:

.mat-dialog-actions {
  // align buttons to right as shown in Material Design guide
  justify-content: flex-end;

.mat-button {
  &:not(:first-child) {
      margin-left: 1em;
    }
  }
}

.flex-spacer {
  flex: 1 1 auto;
}

If I want to push a button to the left side, I put a greedy span in-between the buttons.

<span class="flex-spacer"></span>

But if you want to support RTL layouts, that’s a whole other issue.

3reactions
Splaktarcommented, Jan 4, 2018

@demetrio812 I was able to work around this using the panelClass API of md-dialog, setting my dialog’s ViewEncapsulation.NONE, and applying the following styles to my class:

this.dialog.open(CustomDialogComponent, {panelClass: 'customDialog'})
.customDialog {
  .mat-dialog-container {
    padding: 24px 0 0;

    [mat-dialog-title],
    .mat-dialog-content {
      padding: 0 24px;
    }
    custom-dialog {
      display: flex;
      flex-direction: column;
    }
    .mat-dialog-actions {
      padding: 8px;

      .mat-button {
        padding: 0 8px;
        min-width: 64px;

        &:nth-child(even) {
          margin-left: 8px;
        }
      }
    }
  }
}

These seemed to have the best match with the Material Design spec.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to align buttons in the MdDialog md-dialog-actions block
You can align md-dialog-actions with the align attribute which is available Material 2.0.0-beta.2 on words. Update version if you are not on the...
Read more >
how to prevent mat dialog close on click outside - You.com
1 Answer. import { MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog'; @NgModule ( { providers: [ { provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: { ...
Read more >
Toolbar | Angular Material
<mat-toolbar> is a container for headers, titles, or actions. ... The Material Design specifications describe that toolbars can also have multiple rows.
Read more >
How to Size and Position the MUI Dialog Component - Medium
The Material-UI (MUI) Dialog component is one of the most challenging MUI components to style. It is composed of a modal, container, ...
Read more >
The Form element - HTML: HyperText Markup Language | MDN
If this attribute is not set (and therefore the form is validated), it can be overridden by a formnovalidate attribute on a <button> ......
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