Create Promo Sections using React and Tailwind CSS
Last Updated :
23 Jul, 2025
We’ll learn how to create attractive Promo Sections in a React application using Tailwind CSS. Promo sections are important for highlighting special offers, announcements, or important features. With Tailwind CSS, we can easily style our components and create responsive designs.
Prerequisites
Steps to Create Promo Sections
Step 1: Set up a React Application
npx create-react-app react-app
Step 2: Install node modules using the command.
npm install
cd react-app
Step 3: Install and Configure Tailwind CSS
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Step 4: Configure the tailwind paths in your tailwind.config.js file.
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
Step 5: Add tailwind directives to your index.css file.
CSS
@tailwind base;
@tailwind components;
@tailwind utilities;
body {
overflow: hidden;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
/* App.css */
.course-card {
position: relative;
overflow: hidden;
}
.course-card .absolute {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.3));
transition: opacity 0.3s;
}
.course-card:hover .absolute {
opacity: 1;
}
.java,
.web,
.csharp {
height: 150px !important;
width: 300px !important;
}
Project Structure:
Project StructureUpdated Dependencies:
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
Step 6: Install React Icons
npm install react-icons
Example: In this example we will create promo sections using react and tailwind CSS
JavaScript
// App.js
import React from 'react';
import { FaJava, FaReact, FaPython, FaNodeJs, FaAngular,
FaPhp, FaDatabase } from 'react-icons/fa';
import { SiCsharp, SiRuby, SiSwift, SiKotlin, SiGo } from 'react-icons/si';
import './App.css';
function App() {
return (
<div className="App p-8 bg-green-600 min-h-screen
flex flex-col items-center">
<div className="text-white p-8 flex flex-col items-center">
<h1 className="text-3xl font-bold mb-4">
Limited Time Offer!</h1>
<p className="text-lg mb-4">Get 50% off
on all courses. Don’t miss out!</p>
</div>
<div className="flex flex-wrap justify-center gap-6">
{/* Row 1 */}
<div className="w-full max-w-xs p-6 bg-white
rounded-lg shadow-lg transition-transform transform
hover:scale-105 hover:shadow-xl relative
overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<FaJava />
</div>
<h2 className="text-xl font-bold text-gray-800">Java</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white
rounded-lg shadow-lg transition-transform transform
hover:scale-105 hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500 opacity-0
hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<SiCsharp />
</div>
<h2 className="text-xl font-bold text-gray-800">C#</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500 opacity-0
hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<FaReact />
</div>
<h2 className="text-xl font-bold text-gray-800">Web
Development</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity
duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<FaPython />
</div>
<h2 className="text-xl font-bold text-gray-800">Python</h2>
</div>
</div>
{/* Row 2 */}
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<FaNodeJs />
</div>
<h2 className="text-xl font-bold text-gray-800">Node.js</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<SiRuby />
</div>
<h2 className="text-xl font-bold text-gray-800">Ruby</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<FaAngular />
</div>
<h2 className="text-xl font-bold text-gray-800">Angular</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity
duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<FaPhp />
</div>
<h2 className="text-xl font-bold text-gray-800">PHP</h2>
</div>
</div>
{/* Row 3 */}
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<FaDatabase />
</div>
<h2 className="text-xl font-bold text-gray-800">
Database Management</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<SiSwift />
</div>
<h2 className="text-xl font-bold text-gray-800">Swift</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white
rounded-lg shadow-lg transition-transform transform
hover:scale-105 hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<SiKotlin />
</div>
<h2 className="text-xl font-bold text-gray-800">Kotlin</h2>
</div>
</div>
<div className="w-full max-w-xs p-6 bg-white rounded-lg
shadow-lg transition-transform transform hover:scale-105
hover:shadow-xl relative overflow-hidden course-card">
<div className="absolute inset-0 bg-green-500
opacity-0 hover:opacity-100 transition-opacity duration-300"></div>
<div className="relative z-10 flex flex-col items-center">
<div className="text-4xl text-green-500 mb-4">
<SiGo />
</div>
<h2 className="text-xl font-bold text-gray-800">Go</h2>
</div>
</div>
</div>
</div>
);
}
export default App;
To start the Application run the following command:
npm start
Output:
Conclusion
In summary the React and Tailwind CSS application effectively combines modern design principles with practical functionality. The responsive layout and interactive course cards provide an appealing user experience while the use of Tailwind CSS ensures efficient styling and easy scalability. This project highlights best practices in creating a user friendly and visually attractive web application making it a solid example of integrating React with Tailwind CSS for web development.
Similar Reads
React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version
7 min read
React Fundamentals
React IntroductionReactJS is a component-based JavaScript library used to build dynamic and interactive user interfaces. It simplifies the creation of single-page applications (SPAs) with a focus on performance and maintainability. Why Use React?Before React, web development faced issues like slow DOM updates and mes
7 min read
React Environment SetupTo run any React application, we need to first setup a ReactJS Development Environment. In this article, we will show you a step-by-step guide to installing and configuring a working React development environment.Pre-requisite:We must have Nodejs installed on our PC. So, the very first step will be
3 min read
React JS ReactDOMReactDOM is a core React package that provides methods to interact with the Document Object Model, or DOM. This package allows developers to access and modify the DOM. It is a package in React that provides DOM-specific methods that can be used at the top level of a web app to enable an efficient wa
3 min read
React JSXJSX stands for JavaScript XML, and it is a special syntax used in React to simplify building user interfaces. JSX allows you to write HTML-like code directly inside JavaScript, enabling you to create UI components more efficiently. Although JSX looks like regular HTML, itâs actually a syntax extensi
5 min read
ReactJS Rendering ElementsIn this article we will learn about rendering elements in ReactJS, updating the rendered elements and will also discuss about how efficiently the elements are rendered.What are React Elements?React elements are the smallest building blocks of a React application. They are different from DOM elements
3 min read
React ListsIn lists, React makes it easier to render multiple elements dynamically from arrays or objects, ensuring efficient and reusable code. Since nearly 85% of React Projects involve displaying data collections- like user profiles, product catalogs, or tasks- understanding how to work with lists.To render
4 min read
React FormsForms are an essential part of any application used for collecting user data, processing payments, or handling authentication. React Forms are the components used to collect and manage the user inputs. These components include the input elements like text field, check box, date input, dropdowns etc.
5 min read
ReactJS KeysA key serves as a unique identifier in React, helping to track which items in a list have changed, been updated, or removed. It is particularly useful when dynamically creating components or when users modify the list. In this article, we'll explore ReactJS keys, understand their importance, how the
5 min read
Components in React
React ComponentsIn React, React components are independent, reusable building blocks in a React application that define what gets displayed on the UI. They accept inputs called props and return React elements describing the UI.In this article, we will explore the basics of React components, props, state, and render
4 min read
ReactJS Functional ComponentsIn ReactJS, functional components are a core part of building user interfaces. They are simple, lightweight, and powerful tools for rendering UI and handling logic. Functional components can accept props as input and return JSX that describes what the component should render.Stateless (before hooks)
5 min read
React Class ComponentsClass components are ES6 classes that extend React.Component. They allow state management and lifecycle methods for complex UI logic.Used for stateful components before Hooks.Support lifecycle methods for mounting, updating, and unmounting.The render() method in React class components returns JSX el
4 min read
ReactJS Pure ComponentsReactJS Pure Components are similar to regular class components but with a key optimization. They skip re-renders when the props and state remain the same. While class components are still supported in React, it's generally recommended to use functional components with hooks in new code for better p
4 min read
ReactJS Container and Presentational Pattern in ComponentsIn this article we will categorise the react components in two types depending on the pattern in which they are written in application and will learn briefly about these two categories. We will also discuss about alternatives to this pattern. Presentational and Container ComponentsThe type of compon
2 min read
ReactJS PropTypesIn ReactJS PropTypes are the property that is mainly shared between the parent components to the child components. It is used to solve the type validation problem. Since in the latest version of the React 19, PropeTypes has been removed. What is ReactJS PropTypes?PropTypes is a tool in React that he
5 min read
React Lifecycle In React, the lifecycle refers to the various stages a component goes through. These stages allow developers to run specific code at key moments, such as when the component is created, updated, or removed. By understanding the React lifecycle, you can better manage resources, side effects, and perfo
7 min read
React Hooks
Routing in React
Advanced React Concepts
React Projects