Common Tailwind Attributes and Examples
When declaring attributes you first specify the attribute itself, and apply additional parameters that are separated by hyphens e.g. bg - gray - 100
- Padding/Margin: p, m
- We can specify the axis of padding using keywords x and y. This can be specified even further into single direction using l, r, t, b which stand for left, right, top, and bottom respectively.
- px-4 → Padding only on the X axis, 4 units to the left and right
- mt-10 → Margin at the top of the element 10 units up.
- We can specify the axis of padding using keywords x and y. This can be specified even further into single direction using l, r, t, b which stand for left, right, top, and bottom respectively.
- Width/Height: w, h
- For width and height, we can use fractions, keywords, and absolute values.
- w-full
- h-screen
- w-1/2
- h-16
- For width and height, we can use fractions, keywords, and absolute values.
- Flexbox: flex, items, justify
- Flexbox is quite complicated so we recommend you take a visit to this link to understand it better.
- Font: text, font
- Knowing whether a style is associated with the keyword text or font will only come with practice. Here are some of the common distinctions
- size: text-xl, text-md, text-sm
- bold: font-bold
- color: text-blue-200, text-red-500
- style: italic
- alignment: text-left, text-center, text-justify
- Knowing whether a style is associated with the keyword text or font will only come with practice. Here are some of the common distinctions
- Background: bg
- One of the simpler attributes to modify
- Color: bg-blue-200, bg-red-200
- Gradient: bg-gradient-to-r, bg-gradient-to-t
- Transparency: bg-transparent
- One of the simpler attributes to modify
- Border: border, rounded
- Hover/Focus: hover:bg-opacity-80, focus:outline-none