1
- # PostCSS HWB Function [ <img src =" https://postcss.github.io/postcss/logo.svg " alt =" PostCSS Logo " width =" 90 " height =" 90 " align =" right " >] [ postcss ]
1
+ # PostCSS HWB Function [ <img src =" https://postcss.github.io/postcss/logo.svg " alt =" PostCSS Logo " width =" 90 " height =" 90 " align =" right " >] [ PostCSS ]
2
2
3
- [ <img alt =" npm version " src =" https://img.shields.io/npm/v/@csstools/postcss-hwb-function.svg " height =" 20 " >] [ npm-url ]
4
- [ <img alt =" Build Status " src =" https://github.com/csstools/postcss-plugins/workflows/test/badge.svg " height =" 20 " >] [ cli-url ]
5
- [ <img alt =" Discord " src =" https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white " >] [ discord ]
6
- <br ><br >
7
- [ <img alt =" Baseline Status " src =" https://cssdb.org/images/badges-baseline/hwb-function.svg " height =" 20 " >] [ css-url ]
8
- [ <img alt =" CSS Standard Status " src =" https://cssdb.org/images/badges/hwb-function.svg " height =" 20 " >] [ css-url ]
3
+ [ <img alt =" npm version " src =" https://img.shields.io/npm/v/@csstools/postcss-hwb-function.svg " height =" 20 " >] [ npm-url ] [ <img alt =" Build Status " src =" https://github.com/csstools/postcss-plugins/workflows/test/badge.svg " height =" 20 " >] [ cli-url ] [ <img alt =" Discord " src =" https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white " >] [ discord ] <br ><br >[ <img alt =" Baseline Status " src =" https://cssdb.org/images/badges-baseline/hwb-function.svg " height =" 20 " >] [ css-url ] [ <img alt =" CSS Standard Status " src =" https://cssdb.org/images/badges/hwb-function.svg " height =" 20 " >] [ css-url ]
9
4
10
- [ PostCSS HWB Function] lets you use ` hwb ` color functions in
11
- CSS, following the [ CSS Color] specification.
5
+ ``` bash
6
+ npm install @csstools/postcss-hwb-function --save-dev
7
+ ```
8
+
9
+ [ PostCSS HWB Function] lets you use the ` hwb() ` color function in CSS, following [ CSS Color Module 4] .
12
10
13
11
``` pcss
14
12
a {
15
13
color: hwb(194 0% 0%);
14
+ }
15
+
16
+ b {
16
17
color: hwb(194 0% 0% / .5);
17
18
}
18
19
19
20
/* becomes */
20
21
21
22
a {
22
- color: rgb(0, 195, 255);
23
- color: rgba(0, 195, 255, .5);
23
+ color: rgb(0, 196, 255);
24
+ }
25
+
26
+ b {
27
+ color: rgba(0, 196, 255, 0.5);
24
28
}
25
29
```
26
30
@@ -39,21 +43,26 @@ const postcss = require('postcss');
39
43
const postcssHWBFunction = require (' @csstools/postcss-hwb-function' );
40
44
41
45
postcss ([
42
- postcssHWBFunction (/* pluginOptions */ )
46
+ postcssHWBFunction (/* pluginOptions */ )
43
47
]).process (YOUR_CSS /* , processOptions */ );
44
48
```
45
49
46
50
[ PostCSS HWB Function] runs in all Node environments, with special
47
51
instructions for:
48
52
49
- | [ Node] ( INSTALL.md#node ) | [ PostCSS CLI] ( INSTALL.md#postcss-cli ) | [ Webpack] ( INSTALL.md#webpack ) | [ Gulp] ( INSTALL.md#gulp ) | [ Grunt] ( INSTALL.md#grunt ) |
50
- | --- | --- | --- | --- | --- |
53
+ - [ Node] ( INSTALL.md#node )
54
+ - [ PostCSS CLI] ( INSTALL.md#postcss-cli )
55
+ - [ PostCSS Load Config] ( INSTALL.md#postcss-load-config )
56
+ - [ Webpack] ( INSTALL.md#webpack )
57
+ - [ Next.js] ( INSTALL.md#nextjs )
58
+ - [ Gulp] ( INSTALL.md#gulp )
59
+ - [ Grunt] ( INSTALL.md#grunt )
51
60
52
61
## Options
53
62
54
63
### preserve
55
64
56
- The ` preserve ` option determines whether the original functional color notation
65
+ The ` preserve ` option determines whether the original notation
57
66
is preserved. By default, it is not preserved.
58
67
59
68
``` js
@@ -63,15 +72,21 @@ postcssHWBFunction({ preserve: true })
63
72
``` pcss
64
73
a {
65
74
color: hwb(194 0% 0%);
75
+ }
76
+
77
+ b {
66
78
color: hwb(194 0% 0% / .5);
67
79
}
68
80
69
81
/* becomes */
70
82
71
83
a {
72
- color: rgb(0, 195 , 255);
84
+ color: rgb(0, 196 , 255);
73
85
color: hwb(194 0% 0%);
74
- color: rgba(0, 195, 255, .5);
86
+ }
87
+
88
+ b {
89
+ color: rgba(0, 196, 255, 0.5);
75
90
color: hwb(194 0% 0% / .5);
76
91
}
77
92
```
81
96
[ discord ] : https://discord.gg/bUadyRwkJS
82
97
[ npm-url ] : https://www.npmjs.com/package/@csstools/postcss-hwb-function
83
98
84
- [ CSS Color ] : https://drafts.csswg.org/css-color/#the-hwb-notation
85
- [ Gulp PostCSS ] : https://github.com/postcss/gulp-postcss
86
- [ Grunt PostCSS ] : https://github.com/nDmitry/grunt-postcss
87
99
[ PostCSS ] : https://github.com/postcss/postcss
88
- [ PostCSS Loader ] : https://github.com/postcss/postcss-loader
89
100
[ PostCSS HWB Function ] : https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function
101
+ [ CSS Color Module 4 ] : https://www.w3.org/TR/css-color-4/#the-hwb-notation
0 commit comments