Tailwind CSS tips that save time
Tailwind CSS is fast when the class list stays short. It is slow to read when every exception sits on the same element.
Tips
- Start with layout classes. Then add spacing. Then add color.
- Extract a component when the same class string appears three times.
- Use
gapon the parent. Do not add margin on every child unless you must. - Use one breakpoint set. Prefer
md:andlg:. Do not mix many scales in one view. - Merge classes with a helper such as
twMergewhen props add more classes.
Check
Open a component. If you cannot see the layout in the first line of classes, split the markup. The first line must show display, direction, and width.