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
For JS + inline CSS, we can create an object variable from the text style, then use it whenever the text style needs to be applied to a node. For example:
constheaderStyles={fontSize: "24px",fontWeight: "800"}// inside the component...<divstyle={{...headerStyles,/* other styles */}}>Title</div>
For JS/HTML + Tailwind CSS, there could be multiple approaches:
(JS only) Similar to the inline CSS approach, we can create a string variable from the text style.
constheaderStyles={fontSize: "24px",fontWeight: "800"}// inside the component...<divstyle={{...headerStyles,/* other styles */}}>Title</div>
We could do nothing (following Tailwind's utility-first philosophy)
(For both HTML & JS) Use @apply directive (also recommended by Tailwind)
I like the 3rd option, because if the designer has bothered to create text styles in Figma, they must be frequently used enough to justify it. Also it works across different UI and CSS frameworks.
The text was updated successfully, but these errors were encountered:
Resources:
getStyleById()
to get a text style (reference)Thoughts:
@apply
directive (also recommended by Tailwind)I like the 3rd option, because if the designer has bothered to create text styles in Figma, they must be frequently used enough to justify it. Also it works across different UI and CSS frameworks.
The text was updated successfully, but these errors were encountered: