Replies: 8 comments 12 replies
-
Hey!
Here's an example of how you could do that custom plugin: https://play.tailwindcss.com/ZLp0DzFOSW?file=config Hope it helps 🎉 |
Beta Was this translation helpful? Give feedback.
-
Another way would be to disable the core So what i did in my project was, first add module.exports = {
corePlugins: {
transform: false
}
} Then i had a look at the core plugin, which can be found at https://github.com/tailwindlabs/tailwindcss/blob/master/src/plugins/transform.js Because i am using the const plugin = require('tailwindcss/plugin');
module.exports = {
plugins: [
plugin(function({ addBase, addUtilities, variants }) {
addBase({
'*, ::before, ::after': {
'--tw-translate-x': '0',
'--tw-translate-y': '0',
'--tw-rotate': '0',
'--tw-rotate-y': '0',
'--tw-skew-x': '0',
'--tw-skew-y': '0',
'--tw-scale-x': '1',
'--tw-scale-y': '1',
'--tw-transform': [
'translateX(var(--tw-translate-x))',
'translateY(var(--tw-translate-y))',
'rotate(var(--tw-rotate))',
'rotateY(var(--tw-rotate))',
'skewX(var(--tw-skew-x))',
'skewY(var(--tw-skew-y))',
'scaleX(var(--tw-scale-x))',
'scaleY(var(--tw-scale-y))'
].join(' ')
}
});
addUtilities(
{
'.transform': {
transform: 'var(--tw-transform)'
},
'.transform-cpu': {
'--tw-transform': [
'translateX(var(--tw-translate-x))',
'translateY(var(--tw-translate-y))',
'rotate(var(--tw-rotate))',
'rotateY(var(--tw-rotate-y))',
'skewX(var(--tw-skew-x))',
'skewY(var(--tw-skew-y))',
'scaleX(var(--tw-scale-x))',
'scaleY(var(--tw-scale-y))'
].join(' ')
},
'.transform-gpu': {
'--tw-transform': [
'translate3d(var(--tw-translate-x), var(--tw-translate-y), 0)',
'rotate(var(--tw-rotate))',
'rotateY(var(--tw-rotate-y))',
'skewX(var(--tw-skew-x))',
'skewY(var(--tw-skew-y))',
'scaleX(var(--tw-scale-x))',
'scaleY(var(--tw-scale-y))'
].join(' ')
},
'.transform-none': { transform: 'none' }
},
variants('transform')
);
})
]
} In my case, i added the const plugin = require('tailwindcss/plugin');
const defaultConfig = require('tailwindcss/defaultConfig');
const {
default: prefixNegativeModifiers
} = require('tailwindcss/lib/util/prefixNegativeModifiers');
const map = require('lodash/map');
module.exports = {
plugins: [
plugin(
function({ addUtilities, theme, e }) {
const rotateY = map(theme('rotateY'), (value, key) => {
return {
[`.${e(prefixNegativeModifiers('rotate-y', key))}`]: {
'--tw-rotate-y': value
}
};
});
addUtilities(rotateY);
},
{
theme: {
rotateY: defaultConfig.theme.rotate
}
}
)
]
} I hope that helps. |
Beta Was this translation helpful? Give feedback.
-
For what it's worth - I'd love to see native support baked into tailwind as well to be honest. Using just one svg file to implement a diagonal shape divider, using rotate-x would allow me to use the one svg in both directions. Combining it with rotate alltogether allows me to reuse the one component both on top as well as bottom of the div I want to add the divider to :-) |
Beta Was this translation helpful? Give feedback.
-
I have to add my support for this being natively supported in Tailwind. I was confused to find that "rotate-x", "rotate-y", and "rotate-z" classes were not already a thing. |
Beta Was this translation helpful? Give feedback.
-
I think this would be a great addition to tailwind. |
Beta Was this translation helpful? Give feedback.
-
I made this recently. It’s early days, but I think it has potential to fill this gap and others around 3D transforms. https://github.com/sambauers/tailwindcss-3d A bit lacking in documentation, but should make sense to most folks familiar with Tailwind transforms. |
Beta Was this translation helpful? Give feedback.
-
@sambauers Dude, you just saved me. I was honestly pretty shocked Tailwind hasn't added support for these natively. 3D transforms are super pivotal in CSS animations and transitions. Could you add some usage examples to your repo's README? |
Beta Was this translation helpful? Give feedback.
-
Today I tried Turns out |
Beta Was this translation helpful? Give feedback.
-
My project requires an effect using
rotateX
, I searched and found this PR Add composable transform utilities awesome but without supporting ofrotateX
.Is there any plan or someting for this?
If none, I think I can make contribute to this if others also have requirements.
Pls give me ❤️ if you also want taliwind support
rotateX
.Beta Was this translation helpful? Give feedback.
All reactions