|
1 | 1 | # tailwindcss-textShadow
|
2 | 2 | A Utility Plugins for Text Shadow like Tailwindcss default boxshadow with theme and variants option.
|
| 3 | + |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +#### Yarn |
| 8 | +``` |
| 9 | +yarn add tailwindcss-textShadow --dev |
| 10 | +``` |
| 11 | +#### npm |
| 12 | +``` |
| 13 | +npm i --save-dev tailwindcss-textShadow |
| 14 | +``` |
| 15 | +## Add following changes in tailwind.config.js |
| 16 | + |
| 17 | +#### import the plugin |
| 18 | + |
| 19 | +Add the plugin to the `plugins` array in your Tailwind configuration file `(tailwind.config.js)`. |
| 20 | + |
| 21 | +```javascript |
| 22 | +plugins: [ |
| 23 | + require('tailwindcss-textShadow')() |
| 24 | +] |
| 25 | +``` |
| 26 | + |
| 27 | +#### Set your own text shadow |
| 28 | + |
| 29 | +You can change, add, or remove textShadow property by editing the theme.textShadow section of your Tailwind config. |
| 30 | + |
| 31 | +If a default shadow is provided, it will be used for the non-suffixed `.text-shadow utility`. Any other keys will be used as suffixes, for example the key '2' will create a corresponding `.text-shadow-2` utility. |
| 32 | + |
| 33 | +```javascript |
| 34 | +// tailwind.config.js |
| 35 | +module.exports = { |
| 36 | + theme: { |
| 37 | + boxShadow: { |
| 38 | + default: '0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px 0 rgba(0, 0, 0, .06)', |
| 39 | + md: ' 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06)', |
| 40 | + h1: ' 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -2px rgba(0, 0, 0, .05)', |
| 41 | + xl: ' 0 20px 25px -5px rgba(0, 0, 0, .1), 0 10px 10px -5px rgba(0, 0, 0, .04)', |
| 42 | + 2xl: '0 25px 50px -12px rgba(0, 0, 0, .25)', |
| 43 | + brand: '0 35px 60px -15px rgba(0, 0, 0, .3)', |
| 44 | + outline: '0 0 0 3px rgba(66,153,225,0.5)', |
| 45 | + focus: '0 0 0 3px rgba(66,153,225,0.5)', |
| 46 | + 'none': 'none', |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +``` |
| 52 | + |
| 53 | + |
| 54 | +#### Set Variants in Tailwind Config file |
| 55 | + |
| 56 | +Can use [Tailwind's own variants](https://tailwindcss.com/docs/state-variants/)... |
| 57 | + |
| 58 | +```javascript |
| 59 | +// tailwind.config.js |
| 60 | +variants: { |
| 61 | +//... |
| 62 | + textShadow: ['responsive', 'hover'], |
| 63 | + //... |
| 64 | +}, |
| 65 | +``` |
| 66 | + |
| 67 | +## How to use |
| 68 | + |
| 69 | +#### Responsive |
| 70 | +To control the textshadow of an text element at a specific breakpoint, add a {screen}: prefix to any existing textShadow utility. For example, use md:text-shadow-h1 to apply the text-shadow-h1 utility at only medium screen sizes and above. |
| 71 | + |
| 72 | +```html |
| 73 | +<div class="text-shadow sm:text-shadow-md md:text-shadow-h1 lg:text-shadow-xl xl:text-shadow-2xl ..."> |
| 74 | + <!-- ... --> |
| 75 | +</div> |
| 76 | +``` |
| 77 | + |
0 commit comments