๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
DemoInstallSign in
Socket

tailwindcss-pseudo-elements

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwindcss-pseudo-elements

TailwindCSS Plugin that adds variants of pseudo elements.

1.5.1
Source
npm
Version published
Weekly downloads
3.2K
-17.84%
Maintainers
2
Weekly downloads
ย 
Created
Source

tailwindcss-pseudo-elements

TailwindCSS Plugin that adds variants of pseudo elements (::before, ::after, ::first-letter, etc.).

Usage

Install

NPM

npm install tailwindcss-pseudo-elements --save-dev

Yarn

yarn add tailwindcss-pseudo-elements -D

Configuration

const plugin = require('tailwindcss/plugin')

module.exports = {
  variants: {
    extend: {
      textColor: [
        'responsive',
        'hover',
        'focus',
        'before',
        'after',
        // If you want to combine it with a pseudo class,
        // use `<pseudo-class>_<pseudo-element>`.
        'hover_before',
        'hover_after',
        'focus_before',
        'foo_bar',
      ],
    },
  },

  // You can set up your own pseudo-classes and pseudo-elements.
  customPseudoClasses: ['foo'],
  customPseudoElements: ['bar'],

  plugins: [
    require('tailwindcss-pseudo-elements'),
    // This plugin is useful in combination with tailwindcss-aspect-ratio.
    require('tailwindcss-aspect-ratio')({
      ratios: {
        '16/9': [16, 9],
        '4/3': [4, 3],
        '3/2': [3, 2],
        '1/1': [1, 1],
      },
      variants: ['before', 'hover_before', 'responsive'],
    }),
    plugin(function ({ addUtilities }) {
      addUtilities(
        {
          '.empty-content': {
            content: "''",
          },
        },
        ['before']
      )
    }),
  ],
}

HTML

<div
  class="relative
    before:aspect-ratio-4/3
    hover:before:aspect-ratio-1/1
    before:empty-content"
>
  <img class="absolute pin w-full h-full" src="..." />
</div>

Content Property Utilities

There are utilities that set the attributes of HTML elements to the content property.

Mark it up as follows:

<p
  class="text-lg text-blue-600 content-before content-after content-hover-before"
  tw-content-before="๐Ÿงก"
  tw-content-hover-before="๐Ÿ’–"
  tw-content-after="๐Ÿ’™๏ธ"
>
  Tailwind CSS
</p>

Keywords

tailwindcss

FAQs

Package last updated on 09 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts