Skip to content

Instantly share code, notes, and snippets.

@BigWhale
Last active June 27, 2019 13:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigWhale/1339ad5fc48a08bcc02e9b2a999e7100 to your computer and use it in GitHub Desktop.
Save BigWhale/1339ad5fc48a08bcc02e9b2a999e7100 to your computer and use it in GitHub Desktop.
Tailwind more pseudo classes and variants
variants: {
margin: ['responsive', 'last-child', 'first-child', 'odd-child', 'even-child'],
},
plugins: [
function({ addVariant, e }) {
addVariant('first-child', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`first-child${separator}${className}`)}:first-child`
})
})
},
function({ addVariant, e }) {
addVariant('last-child', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`last-child${separator}${className}`)}:last-child`
})
})
},
function({ addVariant, e }) {
addVariant('odd-child', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`odd-child${separator}${className}`)}:nth-child(odd)`
})
})
},
function({ addVariant, e }) {
addVariant('even-child', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`even-child${separator}${className}`)}:nth-child(even)`
})
})
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment