All Blog Articles

Implementing Tailwind CSS with Payload 3.0

josh
joshuaMay 21, 2025
Transform your Payload CMS 3.0 admin panel with Tailwind CSS utility classes for responsive, beautiful interfaces.

Welcome to another exciting tutorial on Payload NextJS! In this article, we will explore how to implement Tailwind CSS in the Payload CMS 3.0 admin panel. Our guide will take you through each step, ensuring you have a clear understanding of how to enhance your admin panel with Tailwind’s utility-first CSS framework. By the end, you will be equipped with the knowledge to create stunning and responsive UI components in your Payload project.

This article provides a detailed written tutorial complementing our video guide available on YouTube at https://www.youtube.com/watch?v=2-hGLl9hGas. If you're a visual learner or prefer following along with demonstrations, the video covers identical content with real-time implementation of each step and additional context to enhance your understanding of Tailwind CSS integration with Payload CMS 3.0.

Table of Contents

Getting Started with Payload 3.0

To kick things off, we need to set up a new Payload project. The process has become significantly easier compared to previous versions, but there are still essential steps to follow. Let’s dive right in!

Creating a New Payload Project

First, we will initiate a new Payload project using the command line. Open your terminal and run the following command:

npx create-payload-app payload-tailwind

This command creates a new blank project named payload-tailwind. For this tutorial, we will be using MongoDB as our database, but you can opt for any database of your choice.

Connecting to MongoDB

Once the project is created, you will need to set up your MongoDB connection. Copy your MongoDB connection string and paste it into the appropriate configuration file. This step ensures that your application can successfully connect to the database.

Launching the Payload Admin Panel

After setting up your MongoDB connection, it’s time to run the project. Navigate to your project directory and start the development server:

npm run dev

Now, open your web browser and navigate to localhost:3000/admin. This URL will take you to the admin panel where you can manage your content.


Creating an Admin User Account

Upon accessing the admin panel for the first time, you will be prompted to create a user account. Enter your email (for example, test@mail.com) and a password. For demonstration purposes, you can use a simple password like 1234567. Keep in mind that this is just for testing, and you should use a more secure password in production.


Customizing the Dashboard with Tailwind CSS

Now that we have our admin panel up and running, it’s time to make it visually appealing. The default dashboard is quite plain, so let’s enhance it using Tailwind CSS.

Adding a Custom View

To begin, we will create a custom view in the user section of our admin panel. In Payload 3.0, adding custom views differs slightly from previous versions. Instead of directly importing components into configuration files, we will pass a string that represents the path to our React component.

Let’s create a new view for our users:

{
  name: 'Custom View',
  type: 'ui',
  component: 'components/custom-component'
}

In this configuration, we specify the name, type, and the path to our custom component. Now, let’s create a folder for our components, where we will house our Tailwind components.

payload-cms-custom-view-configuration-vscode.jpg


Building a Custom Component

Now, let’s create a new file named custom-component.tsx in the components folder. Here’s a simple React component you can use:

import React from 'react';

const CustomComponent: React.FC = () => {
  return 
Custom View
;
};

export default CustomComponent;

Don’t forget to export your component! After saving the file, navigate back to your view and refresh the page to see your component in action.


Integrating Tailwind CSS

Now that we have our custom view set up, let’s integrate Tailwind CSS into our project. This will allow us to style our components easily and responsively.

Installing Tailwind CSS

To install Tailwind CSS, we can follow the standard installation procedure outlined on the Tailwind website. We will use the following command in our terminal:

pnpm install -D tailwindcss postcss autoprefixer

This command installs Tailwind CSS along with PostCSS and Autoprefixer, which are essential for processing our CSS files.

Initializing Tailwind CSS

After the installation, we need to initialize Tailwind CSS. Run the following command:

npx tailwindcss init -p

This will create the necessary configuration files for Tailwind CSS. One of the critical files you need to configure is the tailwind.config.js file. Here, you should specify which files Tailwind should scan for class names. Update the content property as follows:

content: ['./src/**/*.{js,jsx,ts,tsx}']

This configuration tells Tailwind to look through all the JavaScript and TypeScript files in the src directory.


Creating a Tailwind CSS File

Next, we need to create a tailwind.css file in the src directory. In this file, we will import the necessary Tailwind directives:

@tailwind components;
@tailwind utilities;

Note that we are not importing the base styles since they may interfere with Payload’s default styles.

Importing Tailwind CSS in the Layout

The final step is to import our Tailwind CSS file into the layout of the Payload admin panel. Open the layout.tsx file found in app/payload/admin and add the following import statement:

import '@src/tailwind.css';

payload-admin-layout-tailwind-css-import-setup.jpg


Styling Our Custom Component

Now that we have successfully integrated Tailwind CSS, it’s time to style our custom component. Let’s add some Tailwind classes to our component to make it visually appealing:

const CustomComponent: React.FC = () => {
  return (
    
Custom View

  );
};

By applying these classes, we ensure our text is bold, red, and prominently sized. Save the file and reload your browser to see the changes.


Final Thoughts

Congratulations! You have successfully implemented Tailwind CSS with Payload 3.0 in the admin panel. This integration not only enhances the aesthetics of your admin panel but also improves the overall user experience.

As we anticipate the official release of Payload 3.0, this tutorial will serve as a guide to help you navigate through the new features and enhancements. With Tailwind CSS, you can now create beautiful, responsive components effortlessly.

FAQ

What is Payload NextJS?

Payload NextJS is a headless CMS that allows developers to create and manage content seamlessly using React and Next.js. It provides a flexible API and a customizable admin panel.

Why use Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that enables developers to style their applications quickly and efficiently. It promotes consistent design and makes responsive design easier to implement.

Can I use other databases with Payload?

Yes, Payload supports various databases, including MongoDB, PostgreSQL, and SQLite. You can choose the one that best fits your project requirements.

How can I learn more about Payload NextJS?

To dive deeper into Payload NextJS, check out the official documentation and subscribe to the Payload Newsletter for updates and tutorials.

Thank you for reading! If you found this article helpful, don’t forget to share your thoughts in the comments below and check out our other tutorials for more insights into the world of web development!