Replies: 2 comments 3 replies
-
During mean time, you can roll out a plugin. I sorta was in need for an It required
const plugin = require('tailwindcss/plugin')
const emVariant = function ({ addVariant, e }) {
addVariant('em', ({ container, modifySelectors }) => {
modifySelectors(({ className }) => `.${e(`em:${className}`)}`)
container.walkRules((rule) => {
rule.walkDecls((decl) => {
if (decl.value.match(/^\d\.*\d*/g)) {
decl.value = decl.value.replace(/\D+$/g, 'em')
}
})
})
})
}
const emVariantPlugin = plugin(emVariant)
module.exports = {
variants: {
extend: {
width: ['em'],
height: ['em'],
},
},
plugins: [emVariantPlugin],
} First time dealing with PostCSS thus the code probably isn't optimized. |
Beta Was this translation helpful? Give feedback.
-
This problem is quite severe as soon as one does not have control over the html styling of a page. Our scenario are web components which are embedded into a clients webpage. As tailwind works with rem which is based on the html font size and that is unaccessible in a webcomponent. If our clients' webdeveloper decided to set it html font size to 9px everything gets extremely small and all margins and paddings just do not work anymore. Thus, as soon as one has no control over the html styling, tailwindcss breaks apart. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
First of all, thanks for the amazing framework. :)
Got a situation where I wanted to control checkbox size (width and height with
w-
andh-
classes) as well as its label by adjusting the font size (withtext-SIZE
) of a parent element. This would be possible ifw-
andh-
hadem
unit instead ofrem
, but I understand the trade-offs.So it would be more flexible if you add a new modifier or variant.
Some suggestions:
w-2-em
w-3-px
em:h-2
px:h-3
Beta Was this translation helpful? Give feedback.
All reactions