You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

tailwindcss-children

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwindcss-children

Tailwind CSS plugin to add a variant that targets child elements, as well as first child and last child variants

1.0.0
Source
npmnpm
Version published
Weekly downloads
995
-34.32%
Maintainers
1
Weekly downloads
 
Created
Source

Children Variant Plugin for Tailwind CSS

Installation

npm install tailwindcss-children

Usage

// tailwind.config.js
{
  variants: {
    display: ['children', 'default', 'first-child', 'last-child', 'responsive'],
    borderWidth: ['children', 'default', 'first-child', 'last-child', 'responsive'],
    borderColor: ['children', 'default', 'first-child', 'last-child', 'responsive'],
  },
  plugins: [
    require('tailwindcss-children')(),
  ],
}

The above configuration would generate the following classes:

.children\:block > * {
  display: block;
}

.block {
  display: block;
}

.first-child\:block:first-child {
  display: block;
}

.last-child\:block:last-child {
  display: block;
}

/* etc. */

Which you can then use in your HTML like this:

<ul class="children:block children:border-b children:border-black last-child:border-b-0">
  <li>
    First item
  </li>
  <li>
    Second item
  </li>
  <li>
    Last item, this one doesn't have a bottom border
  </li>
</ul>

You can also override children: classes on specific children if needed:

<ul class="children:block children:bg-gray">
  <li>
    First item
  </li>
  <li class="bg-red">
    Second item, this one has a red background
  </li>
  <li class="bg-blue">
    Third item, this one has a blue background
  </li>
  <li>
    Last item
  </li>
</ul>

The above depends on the order of the generated CSS, so make sure to add the default variant after the children one in the array of variants.

FAQs

Package last updated on 26 May 2019

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.