npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

postcss-pseudo-element-cases

v1.0.0

Published

PostCSS plugin to format pseudo-element casing.

Readme

PostCSS Pseudo-Element Casing

PostCSS plugin to format pseudo elements to uppercase or lowercase.

Turn .fancy-style::BEFORE { into .fancy-style::before { and vice versa.

Jump To Section


Installation

$ npm install postcss-pseudo-element-cases --save-dev

Note: This plugin is for PostCSS.

Usage

With postcss-cli

$ postcss --use postcss-pseudo-element-cases style.css

Note: This requires postcss-cli.

With Node.js:

var fs           = require( 'fs' ),
    postcss      = require( 'postcss' ),
    pseudoCases  = require( 'postcss-pseudo-element-cases' );

const
  options = {
    "case": "upper"
  };

fs.readFile( './style.css', ( err, css ) => {
  postcss( [pseudoCases( options )] )
    .process( css, {
      from: './style.css',
      to: './style.css'
    }).then( result => {
      fs.writeFile( './style.css', result.css,
        function( err ) {
          if ( err ) throw err;
        });
    }).catch( ( err ) => {
      console.log( err );
    });
});

Grunt with grunt-postcss

Running default options:

module.exports = function( grunt ) {
  grunt.initConfig({
    postcss: {
      options: {
        processors: [
          require( 'postcss-pseudo-element-cases' )
        ]
      },
      dist: {
        src: 'src/style.css',
        dest: 'dist/style.css'
      }
    }
  });

  grunt.loadNpmTasks( 'grunt-postcss' );
};

Running custom options:

module.exports = function( grunt ) {
  grunt.initConfig({
    postcss: {
      options: {
        processors: [
          require( 'postcss-pseudo-element-cases' )({
            "selectors": [
                "before",
                "after"
            ],
            "case": "upper"
          })
        ]
      },
      dist: {
        src: 'src/style.css',
        dest: 'dist/style.css'
      }
    }
  });

  grunt.loadNpmTasks( 'grunt-postcss' );
};

Gulp.js with gulp-postcss

var gulp         = require( 'gulp' );
var postcss      = require( 'gulp-postcss' );
var pseudoCases  = require( 'postcss-pseudo-element-cases' );

const
  options = {
    "case": "upper"
  };

gulp.task( 'postcss', function(){
	gulp.src( 'src/style.css' )
		.pipe( postcss( [ pseudoCases( options ) ] ) )
		.pipe( gulp.dest( 'dist' ) );
});

Options

Default Options:

{
  "selectors": [
    "before",
    "after",
    "first-letter",
    "first-line",
    "selection",
    "spelling-error",
    "grammar-error",
    "backdrop",
    "marker",
    "placeholder",
    "shadow",
    "slotted",
    "content"
  ],
  "case": "lower"
}

selectors

Accepts array of pseudo-elements which should have casing enforced in your stylesheet.

case

Accepts "upper" or "lower" for the psudeo-element's casing.

"upper" produces syntax like: .fancy-style::BEFORE {

"lower" produces syntax like .fancy-style::before {

Examples

Enforced Lowercase

Before enforcing lowercase with the case option ( default ):

.fancy-style::FIRST-LINE {
  font-variant: small-caps;
}
.fancy-style:Before, .fancy-style::AFTER {
  content: "";
}
.fancy-style:first-letTer {
  color: blue;
}

After running the PostCSS plugin:

.fancy-style::first-line {
  font-variant: small-caps;
}
.fancy-style:before, .fancy-style::after {
  content: "";
}
.fancy-style:first-letter {
  color: blue;
}

Enforced Uppercase

Before enforcing uppercase with the case option:

.fancy-style::first-line {
  font-variant: small-caps;
}
.fancy-style:BEFORE, .fancy-style:aFter {
  content: "";
}
.fancy-style::First-letter {
  color: blue;
}

After running the PostCSS plugin:

.fancy-style::FIRST-LINE {
  font-variant: small-caps;
}
.fancy-style:BEFORE, .fancy-style:AFTER {
  content: "";
}
.fancy-style::FIRST-LETTER {
  color: blue;
}