Skip to content

Commit f742e8c

Browse files
Introduced dynamic light and dark themes
- automatice theme applied as per user preferred settings - updated readme
1 parent 433612c commit f742e8c

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# css-only-tooltip
22

3+
A very lightweight tooltip utitlity library, made using only `CSS` with dynamic light and dark themes.
4+
35
[![Node.js Package](https://github.com/thoughtlessmind/css-only-tooltip/workflows/Node.js%20Package/badge.svg)](https://github.com/thoughtlessmind/css-only-tooltip)
46
[![NPM downloads](https://badgen.net/npm/dm/css-only-tooltip?icon=npm)](https://www.npmjs.com/package/css-only-tooltip)
57
[![License](https://badgen.net/npm/license/css-only-tooltip)](https://github.com/thoughtlessmind/css-only-tooltip/blob/main/LICENSE)
68
![minified size](https://badgen.net/bundlephobia/min/css-only-tooltip?color=pink)
79
[![npm version](https://badgen.net/npm/v/css-only-tooltip)](https://www.npmjs.com/package/css-only-tooltip)
810
![npm version](https://img.shields.io/github/languages/top/thoughtlessmind/css-only-tooltip)
911

10-
A very lightweight tooltip utitlity library, made using only `CSS`.
1112

1213
## Insatallation
13-
- Using npm
14+
- Using npm
1415
`$ npm install css-only-tooltip`
1516
16-
- Using yarn
17+
- Using yarn
1718
`$ yarn add css-only-tooltip`
1819

1920
- Using jsDelivr CDN
@@ -47,7 +48,15 @@ And then pass the tooltip text in format:
4748
</body>
4849
</html>
4950
```
50-
51+
#### When using Package Manger (NPM/Yarn):-
52+
Import the styleSheet into the main root level component of the App. (for eg. in `App.js` in React App)
53+
```js
54+
import 'css-only-tooltip/dist/styles.min.css';
55+
```
56+
Now, add the text in the `data` attribute in the child components.
57+
```jsx
58+
<data-css-only-tooltip="Hello from tooltip">Hover on me to see the tooltip</span>
59+
```
5160
## Customization
5261
There are customization options provided.
5362
Provide the customization options in a space seperated string in the data attribute like this:-
@@ -64,10 +73,12 @@ Thre are some optional customization options are available.
6473
- `bottom`
6574
- `left`
6675
67-
- #### Themes:
68-
There are two theme options provided. `light` is default option.
76+
- #### Themes:
77+
This supports the user device's theme dynamically. There's no need to specify theme spereately.
78+
Beside this, there are two theme options provided for customization. `light` is default option.
6979
- `dark`
7080
- `light`
81+
7182
---
7283
|Option| Values | default | Required |
7384
|--|--|--|--|

styles.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@
3636
/* -------------------------------------------------------------- */
3737
/* ----------------------- THEMES ----------------------------- */
3838

39+
40+
/* ----- Based on user theme ----- */
41+
@media (prefers-color-scheme: dark) {
42+
[data-css-only-tooltip]::after {
43+
background-color: #222;
44+
color: #fff;
45+
}
46+
}
47+
@media (prefers-color-scheme: light) {
48+
[data-css-only-tooltip]::after {
49+
background-color: #fff;
50+
color: #222;
51+
}
52+
}
53+
3954
/* ----- Dark -----*/
4055
[data-css-only-tooltip-props~="dark"]::after {
4156
background-color: #222;

0 commit comments

Comments
 (0)