![]() The components layer is for class-based styles that you want to be able to override with utilities.The base layer is for things like reset rules or default styles applied to plain HTML elements.To manage this, Tailwind organizes the styles it generates into three different “layers” - a concept popularized by ITCSS. If you’re using something like JSX where the backslash is stripped from the rendered HTML, use String.raw() so the backslash isn’t treated as a JavaScript escape character: In the rare case that you actually need to use an underscore but it’s ambiguous because a space is valid as well, escape the underscore with a backslash and Tailwind won’t convert it to a space: In situations where underscores are common but spaces are invalid, Tailwind will preserve the underscore instead of converting it to a space, for example in URLs: When an arbitrary value needs to contain a space, use an underscore ( _) instead and Tailwind will automatically convert it to a space at build-time: It’s even possible to use the theme function to reference the design tokens in your file: This works for everything in the framework, including things like background colors, font sizes, pseudo-element content, and more: This is basically like inline styles, with the major benefit that you can combine it with interactive modifiers like hover and responsive modifiers like lg: ![]() ![]() When you find yourself really needing something like top: 117px to get a background image in just the right spot, use Tailwind’s square bracket notation to generate a class on the fly with any arbitrary value: While you can usually build the bulk of a well-crafted design using a constrained set of design tokens, once in a while you need to break out of those constraints to get things pixel-perfect. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |