├── LICENSE ├── README.md └── chartmat.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Costantin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tailwindcss-tooltips 2 | Very simple css only tooltips for Tailwind css. See the demo at https://play.tailwindcss.com/2eBipAu8Bt 3 | 4 | # Edit your Tailwind.css file: 5 | Add the followind code on your Tailwind.css file: 6 | 7 | ``` 8 | .tooltip { 9 | @apply invisible absolute; 10 | } 11 | 12 | .has-tooltip:hover .tooltip { 13 | @apply visible z-50 14 | } 15 | 16 | ``` 17 | In the `.tooltip` class you can add some defult syle like `p-1 rounded border border-gray-200 bg-gray-100 shadow-lg ml-4 text-sm` 18 | It's reccomended to add at least `bg-white` to avoid that the tooltip text shows over the partent text. 19 | 20 | If you can't use `@apply` you can add this CSS instead: 21 | 22 | ``` 23 | .tooltip{ 24 | visibility: hidden; 25 | position: absolute; 26 | } 27 | .has-tooltip:hover .tooltip { 28 | visibility: visible; 29 | z-index: 100; 30 | } 31 | ``` 32 | Also in this case in the `.tooltip` class you can add some default padding, text color, background color, etc like `background:#fff;` 33 | 34 | 35 | # Use the tooltips 36 | 37 | To use the tooltip simply wrap a `tooltip` element inside a `has-tooltip` element like this: 38 | 39 | ``` 40 |

41 | Hover me Look at this! 42 |

43 | ``` 44 | You can edit the tooltip position & style using Tailwind CSS classes like so: 45 | 46 | ``` 47 |
48 | Some Nice Tooltip Text 49 | Custom Position (above) 50 |
51 | ``` 52 | 53 | You can also change the position of the tooltip depending on the device using Tailwind's responsive modifiers 54 | 55 | For example: `-mt-1 lg:-mt-8` 56 | 57 | ``` 58 |

59 | Look at this! 60 | Hover me 61 |

62 | ``` 63 | 64 | ## Example: 65 | 66 | You can view a specific example at: 67 | - https://play.tailwindcss.com/2eBipAu8Bt (Reccomended way with @apply) 68 | - https://jsfiddle.net/jvb52qh3/ (Alternative way without @apply) 69 | -------------------------------------------------------------------------------- /chartmat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosbgn/tailwindcss-tooltips/be12ed72306765aea31e4f3e946d70a35f4254ad/chartmat.png --------------------------------------------------------------------------------