Package Exports
- postcss-wcag-contrast
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-wcag-contrast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
WCAG Contrast
WCAG Contrast checks CSS for color contrast compliance with Web Content Accessibility Guidelines (WCAG) 2.0.
.header {
background-color: #444;
color: #000; /* throws a warning for a low contrast of only 2.2 */
}
.footer {
/* wcag-params: bold 14pt #777 */
color: #000; /* throws no warning when text is bold 14pt and contrast is 4.7 */
}
Usage
Add WCAG Contrast to your build tool:
npm install postcss-wcag-contrast --save-dev
Node
require('postcss-wcag-contrast').process(YOUR_CSS, { /* options */ });
PostCSS
Add PostCSS to your build tool:
npm install postcss --save-dev
Load WCAG Contrast as a PostCSS plugin:
postcss([
require('postcss-wcag-contrast')({ /* options */ })
]).process(YOUR_CSS, /* options */);
Gulp
Add Gulp PostCSS to your build tool:
npm install gulp-postcss --save-dev
Enable WCAG Contrast within your Gulpfile:
var postcss = require('gulp-postcss');
gulp.task('css', function () {
return gulp.src('./src/*.css').pipe(
postcss([
require('postcss-wcag-contrast')({ /* options */ })
])
).pipe(
gulp.dest('.')
);
});
Grunt
Add Grunt PostCSS to your build tool:
npm install grunt-postcss --save-dev
Enable WCAG Contrast within your Gruntfile:
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
use: [
require('postcss-wcag-contrast')({ /* options */ })
]
},
dist: {
src: '*.css'
}
}
});
Options
compliance
Type: String
Default: "AA"
Specifies the WCAG compliance the CSS will be evaluated against.
wcag-params
Type: CSS Comment
Specifies additional font size, font weight, background, and foreground information about the rule.