Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
feat(button): Add support for increased touch target to button.
Browse files Browse the repository at this point in the history
  • Loading branch information
joyzhong committed Jul 24, 2019
1 parent 9eb671f commit 67468c3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/mdc-button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ Disabled buttons cannot be interacted with and have no visual interaction effect
</button>
```

## Additional Information

### Accessibility

Material Design spec advises that touch targets should be at least 48 x 48 px.
To meet this requirement, add the following to your button:

```html
<span>
<button class="mdc-button mdc-button--touch">
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">My Accessible Button</span>
<div class="mdc-button__touch"></div>
</button>
</span>
```

Note that the wrapper `<span>` element is only necessary if you want to avoid potentially overlapping touch targets on adjacent elements (due to collapsing margins).

## Style Customization

### CSS Classes
Expand Down
10 changes: 10 additions & 0 deletions packages/mdc-button/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@import "@material/rtl/mixins";
@import "@material/theme/functions";
@import "@material/theme/mixins";
@import "@material/touch-target/mixins";
@import "@material/typography/mixins";
@import "@material/shape/mixins";
@import "@material/shape/functions";
Expand Down Expand Up @@ -61,6 +62,10 @@ $mdc-button-ripple-target: ".mdc-button__ripple";
}
}

.mdc-button__touch {
@include mdc-touch-target($query);
}

@include mdc-button-ink-color(primary, $query);
}

Expand Down Expand Up @@ -116,6 +121,11 @@ $mdc-button-ripple-target: ".mdc-button__ripple";
@include mdc-button--dense_;
}
}

.mdc-button--touch {
@include mdc-touch-target-component(
$component-height: $mdc-button-height, $query: $query);
}
// postcss-bem-linter: end
}

Expand Down

0 comments on commit 67468c3

Please sign in to comment.