# @loipham/material-touch-target

> Touch target mixins and variables for Material Components for the web

Latest version **14.0.4** (published 2022-12-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @loipham/material-touch-target
pnpm add @loipham/material-touch-target
yarn add @loipham/material-touch-target
bun add @loipham/material-touch-target
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: no vulnerabilities; popular repo.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 14.0.4 |
| Published | 2022-12-29 |
| First published | 2022-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17034 |
| Maintainers | loipham |
| Keywords | material components, material design, accessibility, touch target |

## Links

- npm: https://www.npmjs.com/package/@loipham/material-touch-target
- Repository: https://github.com/material-components/material-components-web
- Homepage: https://github.com/material-components/material-components-web#readme
- Issues: https://github.com/material-components/material-components-web/issues
- npm.io page: https://npm.io/package/@loipham/material-touch-target

## Dependencies (4)

- [tslib](https://npm.io/package/tslib.md) ^2.1.0
- [@loipham/material-rtl](https://npm.io/package/@loipham/material-rtl.md) ^14.0.4
- [@loipham/material-base](https://npm.io/package/@loipham/material-base.md) ^14.0.4
- [@loipham/material-feature-targeting](https://npm.io/package/@loipham/material-feature-targeting.md) ^14.0.4

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 14.0.4 (latest) — 2022-12-29
- 14.0.2 — 2022-12-29

## README

<!--docs:
title: "Touch Target"
layout: detail
section: components
excerpt: "Increased touch targets for components"
path: /catalog/touchtarget/
-->

# Touch Target

Touch targets are the parts of the screen that respond to user input. They extend beyond the visual bounds of an element.
For example, a button may appear to be 48 x 36 px, but the padding surrounding it comprises the full 48 x 48 px touch target.

Material Design spec states that touch targets should be at least 48 x 48 px.
The MDC Web library provides mixins and guidance on adding an increased touch target for the following components:
* Button
* Chips
* Checkbox
* Radio
* Mini FAB

## Design & API Documentation

<ul class="icon-list">
  <li class="icon-list-item icon-list-item--spec">
    <a href="https://material.io/design/usability/accessibility.html#layout-typography">Material Design guidelines: Touch Targets</a>
  </li>
</ul>

## Installation

```
npm install @loipham/material-touch-target
```

## Basic Usage

### HTML Structure

For a given button component:

```html
<button class="mdc-button">
  <div class="mdc-button__ripple"></div>
  <span class="mdc-button__label">My Inaccessible Button</span>
</button>
```

You would add an increased touch target as follows:

```html
<div class="mdc-touch-target-wrapper">
  <button class="mdc-button mdc-button--touch">
    <div class="mdc-button__ripple"></div>
    <div class="mdc-button__touch"></div>
    <span class="mdc-button__label">My Accessible Button</span>
  </button>
</div>
```

Note that the outer `mdc-touch-target-wrapper` element is only necessary if you want to avoid potentially overlapping touch targets on adjacent elements (due to collapsing margins).

### Styles

```css
@use "@loipham/material-touch-target/mdc-touch-target";
```

## Style Customization

### Sass Mixins

Mixin | Description
--- | ---
`wrapper` | Applied to the wrapper touch target element.
`touch-target` | Applied to the inner touch target element.
`margin` | Applied to the component root element. Adds margin to compensate for the increased touch target.

---
_Source: https://npm.io/package/@loipham/material-touch-target · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
