Skip to content

Commit ac75add

Browse files
committed
IMP: readme with darkmode
1 parent 93e3e2b commit ac75add

File tree

1 file changed

+61
-3
lines changed

1 file changed

+61
-3
lines changed

README.md

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ module.exports = {
2828
require('@fylgja/tailwindcss-plugin-cssprops')({
2929
tokens: {
3030
colors: {
31-
primary: "200 50% 50%" // HSL color syntax
31+
primary: {
32+
DEFAULT: "200 50% 50%" // HSL color syntax
33+
}
3234
},
3335
},
3436
}),
@@ -43,6 +45,8 @@ module.exports = {
4345
To take it a step further, you can also add your tokens to TailwindCSS colors:
4446

4547
```js
48+
const colors = require("@fylgja/colors/hsl");
49+
4650
module.exports = {
4751
theme: {
4852
extend: {
@@ -58,8 +62,8 @@ module.exports = {
5862
tokens: {
5963
colors: {
6064
primary: {
61-
DEFAULT: "200 50% 50%" // HSL color syntax
62-
}
65+
DEFAULT: colors.purple[8],
66+
},
6367
},
6468
},
6569
}),
@@ -70,3 +74,57 @@ module.exports = {
7074
Now you can use it as `bg-primary`.
7175

7276
For more information on how to use CSS variables in TailwindCSS, refer to the [TailwindCSS docs on using CSS variables](https://tailwindcss.com/docs/customizing-colors#using-css-variables).
77+
78+
### Dark Mode
79+
80+
This plugin fully supports dark mode, just like TailwindCSS. The difference is that you no longer need to define the utilities in your HTML.
81+
82+
To use dark mode tokens, add the key `@media:dark` to your tokens. Anything inside this key will automatically use the dark mode media query.
83+
84+
```js
85+
module.exports = {
86+
theme: {
87+
extend: {
88+
// ...
89+
}
90+
},
91+
plugins: [
92+
require('@fylgja/tailwindcss-plugin-cssprops')({
93+
tokens: {
94+
colors: {
95+
primary: {
96+
DEFAULT: "200 50% 50%" // HSL color syntax
97+
},
98+
"primary-@media:dark": {
99+
DEFAULT: "200 50% 50%" // HSL color syntax
100+
},
101+
// Or use a wrapper as long as the media key is part of the group key, like "colors"
102+
"@media:dark": {
103+
primary: {
104+
DEFAULT: "200 50% 50%" // HSL color syntax
105+
}
106+
}
107+
},
108+
},
109+
}),
110+
],
111+
}
112+
```
113+
114+
If you prefer to use a different class or selector, you can configure it using the `darkmode` option:
115+
116+
```js
117+
module.exports = {
118+
// ...
119+
plugins: [
120+
require("@fylgja/tailwindcss-plugin-cssprops")({
121+
tokens: {
122+
// ...
123+
},
124+
darkmode: "[data-theme=dark]"
125+
})
126+
]
127+
}
128+
```
129+
130+
Feel free to customize the `darkmode` option based on your specific needs and existing CSS classes or selectors.

0 commit comments

Comments
 (0)