CSS Reference ยท Scrolling, Interaction and UI
The touch-action property
Reference for the CSS touch-action property: decide which touch gestures such as panning and pinch-zoom the browser handles, with a live example and notes.
The touch-action property tells the browser which touch gestures it may handle itself on an element, such as panning (scrolling) and pinch-zoom. Gestures you remove are no longer performed by the browser, so your own pointer-event code can use them freely.
It is essential for custom sliders, drawing canvases, maps and drag handles, where a finger drag should move something on the page and not scroll it.
.slider { touch-action: pan-y; }
With pan-y the browser still scrolls the page vertically when a finger moves over the slider, but horizontal drags are left for your script.
Try it
Syntax
touch-action: auto | none | manipulation; touch-action: [ pan-x | pan-left | pan-right ] || [ pan-y | pan-up | pan-down ] || pinch-zoom;
- Initial value:
auto - Applies to: all elements except non-replaced inline elements, table rows, row groups, table columns and column groups
- Inherited: no
- Animatable: no
- Computed value: as specified
Values
| Value | Description |
|---|---|
auto |
The browser decides; all its gestures are allowed. |
none |
The browser handles no gestures here (no pan, no pinch-zoom, no double-tap zoom). |
manipulation |
Allows panning and pinch-zoom, but disables double-tap zoom. |
pan-x, pan-y |
Allow single-finger panning along that axis only. |
pan-left, pan-right, pan-up, pan-down |
Allow panning in a single direction. |
pinch-zoom |
Allows pinch zooming. Combine with the pan keywords. |
Usage notes
- The property is not inherited, but the allowed gestures are the intersection of the element's value with those of its ancestors up to the scroll container, so a parent's restriction still applies to its children.
touch-action: manipulationis a cheap way to remove double-tap zoom on buttons without blocking zoom elsewhere.- Do not use
noneon large areas of a page: you may block scrolling and pinch-zoom, and zoom is an accessibility feature. - The value is read when a gesture starts, so changing it during a gesture has no effect on that gesture.
- Use it together with Pointer Events (
pointerdown,pointermove); touch events alone are not a replacement. - It does not affect mouse input.
Browser support
Widely supported in current browsers, but the full set of keywords such as pan-left or pinch-zoom has not been implemented identically everywhere, so check a compatibility table before relying on the rarer values.
Related
overscroll-behaviorโ scroll chaining and bounceuser-selectโ text selection behaviorcursorโ pointer shape- Lesson: Overflow