Skip to main content

Tailwind CSS is a utility-first CSS framework that provides a comprehensive set of utility classes to streamline front-end development. These utility classes can be combined to build custom designs without the need to write custom CSS from scratch. Here’s a handy cheat sheet to help you navigate and leverage the power of Tailwind CSS:

Full List of Utilities

https://tailwind.build/classes

Spacing

Tailwind CSS provides classes to control padding and margin for elements:

  • p-{size}: Set padding (e.g., p-4 for padding of 1rem).
  • m-{size}: Set margin (e.g., m-2 for margin of 0.5rem).
  • pt-{size}, pr-{size}, pb-{size}, pl-{size}: Set padding-top, padding-right, padding-bottom, and padding-left respectively.
  • mt-{size}, mr-{size}, mb-{size}, ml-{size}: Set margin-top, margin-right, margin-bottom, and margin-left respectively.
  • px-{size}: Set horizontal padding (e.g., px-8 for horizontal padding of 2rem).
  • mx-{size}: Set horizontal margin (e.g., mx-6 for horizontal margin of 1.5rem).

Replace {size} with values like 0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 56, 64, px, auto, etc.

Sizing

You can easily control the width and height of elements with these classes:

  • w-{size}: Set width (e.g., w-64 for width of 16rem).
  • h-{size}: Set height (e.g., h-16 for height of 4rem).

Replace {size} with values like px, full, screen, 1/2, 1/3, 1/4, 2/3, 3/4, etc.

Typography

Tailwind CSS offers a range of classes to style text:

  • text-{size}: Set font size (e.g., text-xl for font size of 1.25rem).
  • font-{weight}: Set font weight (e.g., font-bold for bold text).
  • text-{color}: Set text color (e.g., text-red-500 for red text).
  • text-{alignment}: Align text (e.g., text-center for center-aligned text).
  • line-height-{size}: Set line height (e.g., line-height-8 for line height of 2rem).

Backgrounds

You can control the background color and background image with these classes:

  • bg-{color}: Set background color (e.g., bg-blue-300 for light blue background).
  • bg-{image}: Set background image (e.g., bg-gradient-to-r for right-linear gradient).

Borders

Tailwind CSS allows you to add borders to elements:

  • border-{width}: Set border width (e.g., border-2 for 2px border).
  • border-{color}: Set border color (e.g., border-gray-400 for gray border).
  • rounded-{size}: Set border radius (e.g., rounded-lg for 0.5rem border radius).

Flexbox

Tailwind CSS makes flexbox layout easy with these classes:

  • flex: Enable flexbox layout.
  • flex-{direction}: Set flex direction (e.g., flex-row for horizontal layout).
  • justify-{alignment}: Align items horizontally (e.g., justify-center for center alignment).
  • items-{alignment}: Align items vertically (e.g., items-center for center alignment).
  • flex-wrap: Enable wrapping of flex items.

Responsive Design

To create responsive designs, add breakpoints to your classes:

  • sm, md, lg, xl: Prefix classes with breakpoints for small, medium, large, and extra-large screens.

For example, sm:text-xl will set the font size to 1.25rem on small screens and above.

Shadows

Add box shadows to elements with these classes:

  • shadow-{size}: Set box shadow (e.g., shadow-md for medium shadow).

Interactivity

Tailwind CSS provides classes to handle interactivity:

  • cursor-{type}: Set cursor type (e.g., cursor-pointer for a pointer cursor).
  • pointer-events-{type}: Control pointer events (e.g., pointer-events-none to disable pointer events).

Flexibility

You can control the flex behavior of elements with these classes:

  • flex-1: Expand an element to fill the available space.

Table

Style your tables with these classes:

  • table: Display the element as a table.
  • table-auto: Automatically adjust table width.

Visibility

Control the visibility of elements with these classes:

  • invisible: Hide an element without affecting layout.

Conclusion

Tailwind CSS’s utility classes empower developers to create stylish and responsive designs with ease. By using this cheat sheet, you can quickly reference the available classes and unleash the full potential of Tailwind CSS in your projects.

Remember to consult the official Tailwind CSS documentation for even more in-depth explanations and examples of each utility class.

Leave a Reply