Replies: 2 comments
This comment was marked as spam.
This comment was marked as spam.
|
I've been working on the reverse direction — Tailwind HTML → structured CSS. Been thinking about adding the inverse (CSS → Tailwind) as well. Would love to understand your use case — are you trying to migrate an existing stylesheet into Tailwind classes, or is this for new development? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi Tailwind team,
I’m working on a utility to convert various CSS properties (e.g.,
fontSize,fontWeight,textAlign,display,borderRadius,padding,margin, etc.) into their corresponding Tailwind CSS classes.I have already written a function to handle the conversion, but it requires me to manually write all possible mappings for each CSS property (e.g.,
font-size: 14pxtotext-sm,padding: 16pxtop-4, etc.). This approach works but becomes cumbersome as the number of properties increases.I wanted to ask if Tailwind provides any functions or utility methods to automatically convert or map common CSS properties to Tailwind class equivalents, preferably matching pre-defined classes where applicable. For example:
font-size: 14pxandline-height: 21pxtotext-smpadding: 16pxtop-4text-align: centertotext-centerbox-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1)toshadow-[0px_4px_6px_rgba(0, 0, 0, 0.1)]I’m looking for an efficient way to handle these conversions where:
text-smforfont-size: 14pxorp-4forpadding: 16px).text-[14px]orp-[16px]).Any built-in solutions, utility functions, or best practices from Tailwind would be greatly appreciated!
All reactions