Cooltipz.css is a pure CSS tooltip library that is lightweight, modern, accessible, customisable and easy to use
npm install cooltipz-cssaria-label attributes
data- attributes
cooltipz.css/cooltipz.min.css) - Full version supporting both data attributes and classes
cooltipz-data-attrs.css/cooltipz-data-attrs.min.css) - Lighter version for data-attribute usage only
cooltipz-classes.css/cooltipz-classes.min.css) - Lighter version for class-based usage only
:version with a version listed here (latest version is always recommended). If you always want to get the latest stylesheet, remove @:version completely (Not recommended).
:file with one of the below:
cooltipz.css (Expanded stylesheet)
cooltipz.min.css (Minified stylesheet)
cooltipz-data-attrs.css (Expanded stylesheet)
cooltipz-data-attrs.min.css (Minified stylesheet)
cooltipz-classes.css (Expanded stylesheet)
cooltipz-classes.min.css (Minified stylesheet)
html
`
`css
/ Or CSS /
@import url('https://cdn.jsdelivr.net/npm/cooltipz-css@:version/:file');
`
$3
It's best practice to install Cooltipz.css as a dependency rather than a dev dependency. You can install cooltipz-css via npm or yarn.
_First_ install via npm
`
npm install cooltipz-css --save
`
_Or_ install via yarn
`
yarn add cooltipz-css
`
_Then_ import into your JavaScript
`js
import 'cooltipz-css';
`
_Or_ use the SCSS or CSS into your Sass/SCSS
In the below example, replace :file with one of the options below:
SCSS source files:
- src/cooltipz (.scss file - combined version)
- src/cooltipz-data-attrs (.scss file - data attributes only)
- src/cooltipz-classes (.scss file - classes only)
Compiled CSS files:
- cooltipz.css (Expanded .css - combined version)
- cooltipz.min.css (Minified .css - combined version)
- cooltipz-data-attrs.css (Expanded .css - data attributes only)
- cooltipz-data-attrs.min.css (Minified .css - data attributes only)
- cooltipz-classes.css (Expanded .css - classes only)
- cooltipz-classes.min.css (Minified .css - classes only)
`scss
/ Webpack /
@use '~cooltipz-css/:file' as *;
/ Non-webpack /
@use 'path/to/node_modules/cooltipz-css/:file' as *;
`
---
Choosing the Right Version
Cooltipz.css offers three different versions to help you optimize your bundle size:
$3
- Files: cooltipz.css, cooltipz.min.css, src/cooltipz.scss
- Use when: You want to use both data attributes and classes in your project
- Supports: Both data-cooltipz="tooltip text" and aria-label="tooltip text" with classes like .cooltipz--top
- Size: Full feature set
$3
- Files: cooltipz-data-attrs.css, cooltipz-data-attrs.min.css, src/cooltipz-data-attrs.scss
- Use when: You only use data attributes like data-cooltipz="tooltip text" and data-cooltipz-dir="top"
- Supports: Only data attribute syntax
- Size: ~40% smaller than combined version
- Example:
$3
- Files: cooltipz-classes.css, cooltipz-classes.min.css, src/cooltipz-classes.scss
- Use when: You prefer semantic CSS classes with aria-label attributes
- Supports: Only class-based syntax with aria-label
- Size: ~40% smaller than combined version
- Example:
> 💡 Recommendation: Start with the data attributes only version if you're unsure, as it provides the most intuitive API. You can always switch to the combined version later if needed.
---
License
Type - MIT
Read license
You have the right to use this library in any project FREE of charge for personal and commercial use.
You do not have the right to resell, sublicense or redistribute (even for free) this library.
Cooltipz.css is licensed under MIT. As a minimum, you are required to KEEP AND NOT REMOVE the following code at the beginning of your downloaded/installed Cooltipz.css CSS, where :version is replaced with the version number you are using:
`css
/! Cooltipz.css v:version | MIT License | github.com/jackdomleo7/Cooltipz.css /
`
---
Feedback and support
We appreciate any feedback, good or bad and are always looking for new ideas to improve the user experience (UX), developer experience (DX) and accessibility of the tooltips. You may want to consider:
- Raising a GitHub issue
- Contacting the author directly
- Starring the GitHub repository
- Giving the CodePen a like
- Mentioning 'Cooltipz.css' in a README or footer
- Share on social media
---
Development
$3
- Fork this repository if required
- git clone https://github.com/jackdomleo7/Cooltipz.css.git or clone your forked repository
- cd Cooltipz.css
- npm ci
- npm run build to compile all versions (combined, data-attrs, and classes) from SCSS to CSS
Build commands:
- npm run build - Build all three versions
- npm run build:combined - Build only the combined version (default)
- npm run build:data-attrs - Build only the data attributes version
- npm run build:classes` - Build only the classes version