├── package.json ├── README.md └── index.js /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tailwindcss-touch", 3 | "version": "1.0.1", 4 | "description": "A collection of touch variants for the tailwindcss framework", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/steadfastcollective/tailwindcss-touch.git" 12 | }, 13 | "keywords": [ 14 | "tailwind", 15 | "tailwindcss", 16 | "plugin", 17 | "tailwindcss-plugin" 18 | ], 19 | "author": "steadfastcollective", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/steadfastcollective/tailwindcss-touch/issues" 23 | }, 24 | "homepage": "https://github.com/steadfastcollective/tailwindcss-touch#readme", 25 | "devDependencies": { 26 | "lodash": "^4.17.5" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tailwind Touch Plugin 2 | 3 | This plugin adds a collection of variants to allow fine grain control over how elements appear on touch and non touch devices, CSS Tricks does a great job of detailing how the underlying media queries work you can read more about this here: https://css-tricks.com/touch-devices-not-judged-size. 4 | 5 | ## Installation 6 | 7 | Add this plugin to your project: 8 | 9 | ```bash 10 | # Install via npm 11 | npm install --save-dev tailwindcss-touch 12 | ``` 13 | 14 | ## Usage 15 | 16 | Add the tailwindcss-touch plugin to your plugins key in your tailwind.js config file. 17 | 18 | ```js 19 | plugins: [ 20 | require('tailwindcss-touch')(), 21 | ], 22 | 23 | ``` 24 | 25 | The following variants are currently available: 26 | 27 | ```css 28 | /* pointer-coarse */ 29 | @media (pointer: coarse) { ... } 30 | 31 | /* pointer-fine */ 32 | @media (pointer: fine) { ... } 33 | 34 | /* pointer-none */ 35 | @media (pointer: none) { ... } 36 | 37 | /* hover-hover */ 38 | @media (hover: hover) { ... } 39 | 40 | /* hover-none */ 41 | @media (hover: none) { ... } 42 | ``` 43 | 44 | Enabling a variant on a module is just like enabling any other variant, locate the modules object and add the variants to the module you would like to enable touch capabilites for: 45 | 46 | ```js 47 | modules: { 48 | shadows: ['responsive', 'hover', 'focus', 'hover-hover', 'hover-none'], 49 | }, 50 | ``` 51 | 52 | Once the variant is enabled, using it is just like using any other variant, for example if you have a div which you would like to add a small shadow on touch enabled devices but a large shadow on non touch devices you would do it like so: 53 | ```html 54 |