You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: 14px to text-sm, padding: 16px to p-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:
Converting font-size: 14px and line-height: 21px to text-sm
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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: 14px
totext-sm
,padding: 16px
top-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: 14px
andline-height: 21px
totext-sm
padding: 16px
top-4
text-align: center
totext-center
box-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-sm
forfont-size: 14px
orp-4
forpadding: 16px
).text-[14px]
orp-[16px]
).Any built-in solutions, utility functions, or best practices from Tailwind would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions