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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shimyshack/tailwindcss-pseudo-element-plugin

v1.0.4

Published

A plugin that provides `before` and `after` variants as well as `pseudo-content-{value}` utility classes to Tailwind CSS.

Downloads

44

Readme

@shimyshack/tailwindcss-pseudo-element-plugin

A plugin that provides before and after variants as well as pseudo-content-{value} utility classes to Tailwind CSS.

Installation

Install the plugin from npm:

# Using npm
npm install @shimyshack/tailwindcss-pseudo-element-plugin

# Using Yarn
yarn add @shimyshack/tailwindcss-pseudo-element-plugin

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@shimyshack/tailwindcss-pseudo-element-plugin'),
    // ...
  ],
}

Usage

Use the before and after variants to style the ::before and ::after pseudo elements.

Note: Remember to enable the variants for your specific use cases if not using Tailwind's JIT mode. For example:

// tailwind.config.js
module.exports = {
  variants: {
    extend: {
      display: ['before', 'after'],
      textColor: ['before', 'after'],
      fontSize: ['before', 'after'],
      backgroundColor: ['before', 'after'],
      margin: ['before', 'after'],
    }
  },
}

Use with plugin options

.pseudo-content-both with [data-pseudo-content-both] example:

<div
  data-pseudo-content-both="both"
  class="before:pseudo-content-both after:pseudo-content-both"
>...</div>

.pseudo-content-before and .pseudo-content-after with [data-pseudo-content-before] and [data-pseudo-content-after] example:

<div
  data-pseudo-content-before="before"
  data-pseudo-content-after="after"
  class="before:pseudo-content-before after:pseudo-content-after"
>...</div>

Use the pseudo-content-{value} utilities to specify the content of the pseudo element:

<label
  class="after:inline-block after:text-red-500 after:text-xs after:ml-1 after:font-bold after:pseudo-content-asterisk xl:after:pseudo-content-required"
>
  Field Name
</label>

Use with JIT

Use the pseudo-content-[value] utilities to specify the content of the pseudo element.

Spaces must be underscore characters:

<div class="before:block before:bg-red-500 before:pseudo-content-[Whatever_you_want_to_say]">
  ...
</div>

More Examples

An example of a punctuated list:

<ul class="inline-block">
  <li class="inline-block after:inline-block after:pseudo-content-comma after:mr-1">Item 1</li>
  <li class="inline-block after:inline-block after:pseudo-content-comma after:mr-1">Item 2</li>
  <li class="inline-block after:inline-block after:pseudo-content-oxford-ampersand after:mr-1">Item 3</li>
  <li class="inline-block">Item 4</li>
</ul>

An example of using a unicode character:

<div
  class="inline-block after:inline-block after:pseudo-content-[\b7] after:mx-1"
>...</div>

Configuration

The following code snippet shows the default pseudo-content-* options as well as the default variants generated for before and after.

You can configure which values are generated by using the pseudoContent key and you can configure which variants are generated by this plugin under the pseudoElements key in your tailwind.config.js file.

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      pseudoContent: {
        empty: '""',
        space: '" "',
        required: '"* required"',
        asterisk: '"*"',
        ampersand: '"&"',
        and: '"and"',
        'oxford-ampersand': '", &"',
        'oxford-and': '", and"',
        comma: '","',
        middot: '"\\b7"',
        mdash: '"\\2014"',
        bar: '"|"',
        gt: '">"',
        lt: '"<"',
        both: 'attr(data-pseudo-content-both)',
        before: 'attr(data-pseudo-content-before)',
        after: 'attr(data-pseudo-content-after)'
      }
    }
  },
  variants: {
    pseudoElements: ['responsive', 'before', 'after'],
  }
}