Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

csstools/postcss-space-start-attrs

Repository files navigation

Space Start Attributes PostCSS Logo

NPM Version Build Status Licensing Changelog Gitter Chat

Space Start Attributes targets attributes beginning with a certain value in a space separated list in CSS.

/* before */

div[data-thing~^"starts-with"] {
	background-color: red;
}

div:not([data-thing~^"starts-with"]) {
	background-color: blue;
}

/* after */

div[class^="starts-with"],div[class*=" starts-with"] {
	background-color: red;
}

div:not([class^="starts-with"],[class*=" starts-with"]) {
	background-color: blue;
}

Note: The above example generates a W3C CSS level 4 :not() selector. I recommend using Selector Not to transpile this to a more compatible CSS level 3 selector.

Usage

Add Space Start Attributes to your build tool:

npm install postcss-space-start-attrs --save-dev

Node

require('postcss-space-start-attrs').process(YOUR_CSS, { /* options */ });

PostCSS

Add PostCSS to your build tool:

npm install postcss --save-dev

Load Space Start Attributes as a PostCSS plugin:

postcss([
	require('postcss-space-start-attrs')({ /* options */ })
]).process(YOUR_CSS, /* options */);

Gulp

Add Gulp PostCSS to your build tool:

npm install gulp-postcss --save-dev

Enable Space Start Attributes within your Gulpfile:

var postcss = require('gulp-postcss');

gulp.task('css', function () {
	return gulp.src('./src/*.css').pipe(
		postcss([
			require('postcss-space-start-attrs')({ /* options */ })
		])
	).pipe(
		gulp.dest('.')
	);
});

Grunt

Add Grunt PostCSS to your build tool:

npm install grunt-postcss --save-dev

Enable Space Start Attributes within your Gruntfile:

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
	postcss: {
		options: {
			use: [
				require('postcss-space-start-attrs')({ /* options */ })
			]
		},
		dist: {
			src: '*.css'
		}
	}
});

About

Target attributes beginning with a certain value in a space separated list

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published