Last active
October 12, 2020 12:12
-
-
Save masahirompp/7fb18cf56a1d9a1a0bb357e0881f075d to your computer and use it in GitHub Desktop.
tailwind css next-sibling margin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
.-ml-px { | |
margin-left: -1px; | |
} | |
.child-siblings\:m-0 > * + * { | |
margin: 0; | |
} | |
.child-siblings\:m-1 > * + * { | |
margin: 0.25rem; | |
} | |
.child-siblings\:m-2 > * + * { | |
margin: 0.5rem; | |
} | |
... | |
... | |
@media (min-width: 640px) { | |
.sm\:-ml-px { | |
margin-left: -1px; | |
} | |
.sm\:child-siblings\:m-0 > * + * { | |
margin: 0; | |
} | |
.sm\:child-siblings\:m-1 > * + * { | |
margin: 0.25rem; | |
} | |
.sm\:child-siblings\:m-2 > * + * { | |
margin: 0.5rem; | |
} | |
... | |
} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const plugin = require('tailwindcss/plugin') | |
module.exports = { | |
theme: { | |
extend: {} | |
}, | |
variants: { | |
margin: ['responsive', 'child-siblings'] | |
}, | |
plugins: [ | |
require('@tailwindcss/custom-forms'), | |
plugin(function({ addVariant, e }) { | |
addVariant('child-siblings', ({ modifySelectors, separator }) => { | |
modifySelectors(({ className }) => { | |
return `.${e(`child-siblings${separator}${className}`)} > * + *` | |
}) | |
}) | |
}) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment