Children Variant Plugin for Tailwind CSS
Requirements
This plugin requires Tailwind CSS 1.2 or later. If your project uses an older version of Tailwind, you should install the latest 1.x version of this plugin (npm install tailwindcss-children@1.x
).
Installation
npm install tailwindcss-children
Usage
// tailwind.config.jsmoduleexports = variants: display: 'children' 'default' 'children-first' 'children-last' 'children-odd' 'children-even' 'children-not-first' 'children-not-last' 'children-hover' 'hover' 'children-focus' 'focus' 'children-focus-within' 'focus-within' 'children-active' 'active' 'children-visited' 'visited' 'children-disabled' 'disabled' 'responsive' plugins: ;
The above configuration would generate the following CSS:
/* etc. */
Which you can then use in your HTML like this:
First item Second item Last item, this one doesn't have a bottom border
You can also override children:
classes on specific children if needed:
First item Second item, this one has a red background Third item, this one has a blue background Last item
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 (as well as the hover
variant after the children-hover
variant if you want to override a children:hover:*
utility, etc.).