diff --git a/src/material-experimental/mdc-button/_button-base.scss b/src/material-experimental/mdc-button/_button-base.scss index 9b6a0f9220dc..181545166969 100644 --- a/src/material-experimental/mdc-button/_button-base.scss +++ b/src/material-experimental/mdc-button/_button-base.scss @@ -1,3 +1,5 @@ +@use '@material/touch-target' as mdc-touch-target; +@use '../mdc-helpers/mdc-helpers'; @use '../../material/core/style/layout-common'; // Adds styles necessary to provide stateful interactions with the button. This includes providing @@ -59,3 +61,19 @@ pointer-events: none; } } + +@mixin mat-private-button-touch-target($is-square) { + // Pseudo element used to ensure that the button has a touch target that meets the required + // minimum. Note that we use this, instead of MDC's built-in `mdc-button--touch` class, because + // the MDC class is implemented as `margin-top: 6px; margin-bottom: 6px` on the host element which + // goes against our rule of not having margins on the host node. Furthermore, having the margin on + // the button itself would require us to wrap it in another div. See: + // https://github.com/material-components/material-components-web/tree/master/packages/mdc-button#making-buttons-accessible + &::after { + content: ''; + + @include mdc-touch-target.touch-target( + $set-width: $is-square, + $query: mdc-helpers.$mat-base-styles-query); + } +} diff --git a/src/material-experimental/mdc-button/button.scss b/src/material-experimental/mdc-button/button.scss index 1ca09d997b9c..62b10a18d10c 100644 --- a/src/material-experimental/mdc-button/button.scss +++ b/src/material-experimental/mdc-button/button.scss @@ -2,7 +2,7 @@ @use '@material/button/variables' as mdc-button-variables; @use '../mdc-helpers/mdc-helpers'; @use '../../cdk/a11y'; -@use '_button-base'; +@use 'button-base'; @include mdc-button.without-ripple($query: mdc-helpers.$mat-base-styles-query); @@ -10,6 +10,7 @@ .mat-mdc-button, .mat-mdc-unelevated-button, .mat-mdc-raised-button, .mat-mdc-outlined-button { @include button-base.mat-private-button-interactive(); @include button-base.mat-private-button-disabled(); + @include button-base.mat-private-button-touch-target(false); } // MDC expects button icons to contain this HTML content: diff --git a/src/material-experimental/mdc-button/fab.scss b/src/material-experimental/mdc-button/fab.scss index 4aa590867d66..074015505382 100644 --- a/src/material-experimental/mdc-button/fab.scss +++ b/src/material-experimental/mdc-button/fab.scss @@ -1,12 +1,13 @@ @use '@material/fab' as mdc-fab; @use '../mdc-helpers/mdc-helpers'; -@use '_button-base'; +@use 'button-base'; @include mdc-fab.without-ripple($query: mdc-helpers.$mat-base-styles-query); .mat-mdc-fab, .mat-mdc-mini-fab { @include button-base.mat-private-button-interactive(); @include button-base.mat-private-button-disabled(); + @include button-base.mat-private-button-touch-target(true); // MDC adds some styles to fab and mini-fab that conflict with some of our focus indicator // styles and don't actually do anything. This undoes those conflicting styles. diff --git a/src/material-experimental/mdc-button/icon-button.scss b/src/material-experimental/mdc-button/icon-button.scss index f7daec321298..7088c836934b 100644 --- a/src/material-experimental/mdc-button/icon-button.scss +++ b/src/material-experimental/mdc-button/icon-button.scss @@ -13,6 +13,7 @@ border-radius: 50%; @include button-base.mat-private-button-disabled(); + @include button-base.mat-private-button-touch-target(true); // MDC adds some styles to icon buttons that conflict with some of our focus indicator styles // and don't actually do anything. This undoes those conflicting styles.