Quick reference

Class
Properties
touch-autotouch-action: auto;
touch-nonetouch-action: none;
touch-pan-xtouch-action: pan-x;
touch-pan-lefttouch-action: pan-left;
touch-pan-righttouch-action: pan-right;
touch-pan-ytouch-action: pan-y;
touch-pan-uptouch-action: pan-up;
touch-pan-downtouch-action: pan-down;
touch-pinch-zoomtouch-action: pinch-zoom;
touch-manipulationtouch-action: manipulation;

Basic usage

Setting the touch action

Use the touch-{action} utilities to control how an element can be scrolled (panned) and zoomed (pinched) on touchscreens.

Try panning these images on a touchscreen

touch-auto

touch-none

touch-pan-x

touch-pan-y

<div class="w-full h-48 overflow-auto touch-auto ...">
  <img class="w-[150%] max-w-none h-auto" src="..." />
</div>
<div class="w-full h-48 overflow-auto touch-none ...">
  <img class="w-[150%] max-w-none h-auto" src="..." />
</div>
<div class="w-full h-48 overflow-auto touch-pan-x ...">
  <img class="w-[150%] max-w-none h-auto" src="..." />
</div>
<div class="w-full h-48 overflow-auto touch-pan-y ...">
  <img class="w-[150%] max-w-none h-auto" src="..." />
</div>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use focus:touch-pan-x to only apply the touch-pan-x utility on focus.

<div class="focus:touch-pan-x">
  <!-- ... -->
</div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:touch-pan-x to apply the touch-pan-x utility at only medium screen sizes and above.

<div class="md:touch-pan-x">
  <!-- ... -->
</div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.