- Podcasts
- ReactJS Developers Podcast
- Master Tailwind CSS for React Developers | Essential Concepts, Tips & Best Practices
Master Tailwind CSS for React Developers | Essential Concepts, Tips & Best Practices
ReactJS Developers Podcast
- December 3, 2026
- 1 h 15 min
- Episode 36
About this episodeTailwind CSS has become one of the most popular styling frameworks for modern frontend development, especially among React developers. But…
- Understanding the utility-first approach of Tailwind CSS.
- Why React developers use Tailwind CSS.
- Applying utility classes to React components.
- Creating responsive layouts using breakpoints.
- Working with Flexbox and CSS Grid utilities.
- Customising colours, spacing, typography, and themes.
- Handling hover, focus, and other interactive states.
- Building reusable UI components.
- Avoiding common Tailwind CSS mistakes.
- Improving code readability and maintainability.
- Best practices for using Tailwind CSS in React projects.
- React JS developers learning modern CSS frameworks.
- Beginners interested in Tailwind CSS.
- Frontend developers building responsive websites.
- JavaScript developers transitioning to modern frontend development.
- Developers who want to improve their UI styling workflow.
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Master Tailwind CSS for React Developers | Essential Concepts, Tips & Best Practices
In this video, I am going to teach you complete tailwind CSS and a small project as well. After this lecture, I don't think you will need to learn tailwind CSS from anywhere else. You will master the whole tailwind CSS and I guarantee it. You will learn the complete tailwind CSS from here. I have divided it into four phases, but before learning tailwind CSS, let me.
Our style lecture is already available in our react playlist. If you don't know, then you must have already known. So, please follow the playlist. In our style lecture, I have told you how to style, what is the production approach, what are the problems in normal CSS, and what we can use to solve them. If you have seen all that, then the first point is Y-tailwind.
After that, you will know that Y-tailwind. And then in the second phase, I have talked about four phases. In the second phase, we will talk about installation of Tailwind. How to install Tailwind? Many people get stuck here. So proper method, how to read documentation, how to install, and how to make documentation by reading.
Css if you know medium then it is very good because I will also teach you how to write in medium alright so you should know basic css how to write by reading basic usage documentation I will teach you all this is a small project but but you don't have to understand that in this small project I have told and finished We don't have to understand this because this is a small project to understand tailwind. After this, we will use tailwind in all the lectures that will come. If you want to make any small project, if you want to understand any concept, if you want to do style, then we will use tailwind. If you want to do anything, then we will use tailwind. After this, I will use tailwind in all the lectures.
So what will people do in our application of beat? I have cleaned everything in app.css for a long time. I will make it a little smaller. Everything is neat and clean. So that your time is not wasted. Then we have app.css completely clean. We have index.css completely clean. If you don't have it, then do it.
Why? Because we have imported app.css here. So definitely it will work in this file. we have imported app.jsx so whatever work we will do in app.jsx will be applied to it so we select natural and here we have given background color red these are basic things so here it has become red very good so we will come back here so in app.jsx I had imported app.jsx so it has been applied here so it is understandable but but if I make any other component like card.jsx.
This card in app.jsx how to use this card and it will be imported automatically very good we are using the card here the card has come so how to import it automatically how to do this you should be clear about this if you are not getting the fundamentals then why do you jump directly see it is running in the sequence I have given it in the proper roadmap in the sequence so here is our card now see carefully I have imported here app.css I have imported here but if I use h1 tag in card so I have selected h1 tag in app.css see here I have selected h1 tag but you must be thinking that I have imported app.css in this file so it should work in this file but it is not like that it will work in card also see here I have written h1 here So this will also be styled. So it works globally.
Are going to see tailwind CSS. The problem of CSS is over, tailwind CSS. And we have made many libraries where we have made many components. We have seen many things but it is good to see step by step. So what should I remove now? I will not give you a video on card component for now. Let us understand tailwind CSS for now. Now we will see how to use tailwind css for installation but first understand how tailwind css works Listen carefully I have styled app.css as h1 Alright I have shown h1 as hello how are you I have styled h1 as tag.
I said that you made the class and then you came here and used it. And the problem is that CSS is leaking everywhere. CSS is leaking everywhere. Then I said that Tailwind CSS is used to solve this problem. How does Tailwind CSS work? They were making the class here and then they were using the class here. I said that if it is not already made, So this is even better, we will not get the already made one, we just have to use it and it will work.
Now what you have to do here, you will get the class made, you have to keep writing the class, How to write the class, what will be the name of the class, how will you know all that I will tell you now. All things just keep a little patience. Now our first one is completed, white. The problem was that CSS was not working and we were making it in a different file and then we were using it. And because git works for our component, react works for our component. So why not make a component with classes and make a style of it.
After that, supported by the best, you can write a responsive design with tailwind. The most important thing is that you can write a responsive design and you can also write your own ESM. If you don't have a bootstrap, you can use the glasses that are not made in bootstrap. Here you can also write your own ESM through tailwind. After that, there are a lot of things, a lot of things, you can see here, read it.
When you come in the starting, This is the starting page, come to docs, you will find that you have to install the beat project first. So we have done this, brother, there is no need to do this. We have installed the beat project and in the beat folder also, this CD my project, we have given the name of our project, here also we have given my project, we have given the name of the project as beat. And we are in the beat folder, so this is not the beat to run completely. You understand, you just have to copy and paste. We have already done this, beat is our second. To tailwind, we will use this command. Here we will install tailwind css. We are doing everything here, tailwind.
Get ps5, but js If you are fusing javascript, then js If you are fusing types, then ts will be there So here is our js So what we have already done, we don't have to delete it Alright What you have to do here, these two lines are highlighted here These two lines, only this much is missing, so you don't have to delete this much means we have to.
Then import tailwind css import tailwind css to your css file import tailwind css to your main css file which is the main css file? definitely main css file is index.css that's why i didn't delete it index.css is your global css file so import tailwind css to your css file no problem? no here you have to come.
Style is already done. You just have to use them. If I want to do BG red, I will do red. If I want to do BG blue, I will do BG blue. And I am getting suggestions because I have installed extension. You are not getting any suggestions. So, BG blue and I will give you the background once again. This is normal CSS rule.
You will get to know how to use basic in one button making so here I have made a button click me now here I have to style it see how it is looking now it is looking bad so what I have to do to make a button first of all I have to give some background color so how to give background color you don't know I have just told you but you don't know assume you don't know so what you have to do is come to the tailwind site and here you have a search option.
Enter background-color enter the background color and it will tell you how to add background you have to give these classes and this style you will get this style if you use this class you will get this style if you use this class if you want to give white background color then write bg white here then your color will be white if you want to give black then write bg.
Border-radius. So just search as it is. Interpret. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded.
If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded. If you want a small border radius, then you have to write rounded small means 4px 0.25 medium means 6px 0.375 if you want you can read it but in styling we don't read it we use heat and trial method if it is big then we use small if it is big then we use extra small if it is small then we use large if it is bigger then we use xl if it is bigger then we use 2xl it is very simple If you want to read properly how many pixels or how many REMs are there, you can read it here. The proper way to create documentation.
Now you have to give the number of p. So you get padding on all sides. Padding and here in pixel in pixels, what is this? ppx means padding 1px if you give ppx means padding 1px ok and you can give some number if you give any number here then it is equal to 4px somewhere it is written here I have read like padding top is 6 padding.
Want to give padding of 3 from bottom I want to give padding of 8 from left And I want to give padding of 16 from right This is how it is done Top is of 10, bottom is of 2, left is of something, right is of 16 This is how your padding is done So if you want padding of x to be equal and y to be different If you want to do this, how will you do it?
Of x and y Padding in x to enter padding in x search padding then it will give straight while searching it will not give enter so i am not entering padding here so it will enter here only so i am not entering padding now it is padding now i will enter padding if i will enter px then padding will.
Padding in line padding x to px padding y to py you can see this and understand it by doing a little bit of written trial padding x to px like padding right to pr padding x to px it will give padding from left to right from left to right so let's say 10 here so it will give only x nothing in y I have to give something from the top, like padding from the top I will give padding 3 from the top, sorry not from the top, from the padding y I gave padding 3 from the top and from the bottom and one number is equal to 4 pixels.
So far, we have done the installation of Tailment and the basic usage. We have learned by making a button. Basic usage. Now we will make a small project where we will get some idea of flex, some idea of grid and normal font sizing, background color etc. Overall you can say that you will understand tailwind and you will also understand media.
We will make a header with this. I will make a small hero section and a footer. I have selected a little different and good one. So that you can get Tailwind CSS better. You are able to make good designs. So I believe you can make this footer from Tailwind CSS. So your grid layout will be practiced. And if you make this header and this section, then flex will be practiced. Rest color etc. and padding will be covered in this. Rest if you make it a little responsive, then media query will also be practiced. So let's start making it quickly. Here comes our application is running here. And first of all, we will not break our components, we will break the components and see, but for now let's start making it. So first of all, we will make a new bar. Okay, not like this, new or you can use the header like this and what we have to do here, first of all, Let's see how one of our brand logo will come here. We are not putting an icon here. One logo will come here. Four menus will come here and a button on the side. So let's quickly style this. So it will be fun. First of all, here is one H1. This is our logo. Let's write brand here. And in brand, let's style B a little bit. Let's style B a little bit. Let's put it in this pen tag. so that we can style B separately. I am not adding an icon, so I am keeping it simple. We will style B separately here and our brand will be here. And then after that we need some menus. Alright, let's make a div here in the anchor tag. First of all, what is ours here?
Integrations and you can see html etc integrations and in the end you can write any portfolio I have copied and pasted everything here. Although here it was about us. I wrote the portfolio. You have to make an exact, make an exact. We have nothing to do with that now. Now our purpose is to learn Tailwind CSS. Then there is a button of join us or you can say sign in. So here we will quickly make a button. And let's write join us here.
I will tell you now. I wrapped it inside div because I will give this style to the header. First of all, I will give flex. It will come in one line. Now you must be thinking that everything is stuck. As soon as I justify, you have read the normal flex box. Let's do display flex and then justify content center, justify content space between. I am doing justify space between here. Not space between, but between. If you are getting suggestions, then I am taking it. If you are not getting it, then do documentation. So, I have given display flags. And I have given justify content space between. So that all of them take equal space in between. Now see, you must be seeing something like this. All of them took equal space in between. Here it was one element. Look carefully. See, this H1 is one element of ours. There are three child in this header. One is h1, one is div and one is button. So, we have used space between these three. So, evenly spaces have come in between. Now, what we have to do? Now, we have to do that in between this, this is our menu, features, use cases, integrations, portfolio. I need equal spaces between them. So what I will do is flex the display of this lib. I will give it a flex class and it will be flexed. And then I will give a gap of 7 here. So there is a gap in between. Now see it is looking pretty. And let's do it like this. And let's increase its size a little. So to increase the size, our font size used to be in CSS.
First of all, everyone's color is black here, so black is not looking much better here. I will give BG black here. I gave BG black, not BG, text black. I want the color of the text, so I will give text black here. In normal CSS, background color and normal color used to be the same. Normal color used to change the color of the text and background color used to change the color of the background. For background color, we use BG and for normal color, we use text and dash.
I have given the text black, so now black is coming here, it was already black, we have done it separately. So we want to make it a little transparent so that the opacity of black is a little less and it is a little visible in silver color. So black here we use the divide symbol and from here we can give opacity. Like I will give it a little 30 so it will be very transparent. If I give 100, then it is fully black in this way. And if I want to reduce it a little, then I give 80.
It will be a little transparent. So you can understand how it is happening. 100 means 100% is its opacity. Opacity 1 is in normal CSS. Opacity 1 means it will be seen completely. So here 100 means it is seen completely. If we keep reducing, then it will be reduced. Like 0.1, 0.2, 0.3 used to happen there. Here you can write 10, 20, 30, 40 in this way.
And I want to fix the width of the header. This is our header, I will fix its width here. I want the maximum width not to be more than 60 rem. Now how will I give 60 rem? If I have to give 60 rem, then I can't give it. I can give it. This is tailwind. Here open and close the square bracket in this way. And here 60 rem. The normal CSS had maximum width. That is 60rem. So maximum width 60rem means it will go till 60rem. It will not go more than that. It can be less than that. It can't be more than that. Normal CSS is coming. Maximum width 60rem means it will be max to max 60rem. It can be less than that. It will never go more than that. Max to max 60. Not more than that.
So let's treat it like a button. Let's style it like a button. So in this class name. For the button, first of all, we will give BG. Let's give tomato. We have selected the tomato theme. So let's give tomato. And for border radius, tell me quickly what we use for border radius. Tell me quickly. For border radius, we use rounded, large, xl, double xl. Okay, you can see that. This is done. Then I need a little padding from x. So I give padding x as 3. 3 means 3 4 is 12, 12 pixels. 1 has 4 pixels, so 3 has 12 pixels. So this is our 12 pixels. Alright, and we give padding y. Padding from Y to 2. So this is looking good. The join button is looking good. We can increase the padding a little more. We can give 4. Wait a minute. Padding X to 4. So this I believe is looking good. And this is looking a little crispy. This is looking up, not in the middle. So now this is our one. What can we call it?
You can see that according to you. So here we make this portion the best way to review creative assets. And here are some paragraphs and again there is a button. So let's make it quickly, we will break it in the component later. Or if you want, let's break it in the component. Let's make a component folder here. I have told you all this, so practice will also be done. I made a folder called components. I will make a header component in this. Give the name in capital. header.jsx rafce and this whole header. I will cut this whole header from here. And I will paste it here. This whole header is ready. And we will import this header here.
And text alignment, if we have to center it, text alignment center. So here normally we write text center and it becomes text alignment center. So the work related to font you can do by writing text. Like if we have to align related to text then we used to write text align in CSS. Here we just have to write text center. It will make text align center. And you are understanding this margin like we used to do in padding. Let's take a little padding. Let's take padding y of 10. So, it's looking a little less. So, let's take it straight in REM. How much REM should I take?
It will be better. 8 REM is looking good. And, it's looking good. It's looking good. It's looking a little good. And, let's see how this heading font looks after bold. Bold is looking like this. Anything else other than bold? Bold, extra bold, extra light, light, medium, mono, normal, sense, You can also use font-family. How will it look like? It looks like this. Is font-verdana or font-verdana?
You will also get to know about the font weight, what are the changes, etc. The color of the review is a little different. In the review, we will use the span tag. We will put the review in the span tag and give the class name here. use span tag in the review. here put the review in the span tag and here again give the class name. bg give the color of the header, it will look good. bg red 300 was in the header. so it is looking good. and we will do one thing, we will give its maximum width 55rem. so it will look something like this, it is looking perfect now. And we have to make it a little bit rounded. So to make it rounded, here border radius basically. Let's give it large, it will be enough. Large is looking good. There is a little more rotation here. So let's do the excel here. Now it is looking good and we will give a little bit of padding x of 3. So it will look a little better. Yes, it is looking good. Actually, if you give 2x instead of x, it will look good. Now you can make it bigger according to you. Now it is looking more perfect. There is a paragraph below it. Just below it. This is our paragraph. Let's give it loram 20. So this is our paragraph. It is small and cute. And we will increase its size a little bit. Let's make the text medium. The text should not be sad. Wait a minute. Text 2xl, 3xl, medium, text large. Text large. So large is looking good. And there is a little space below it actually. There is space above and below it. Let's take a button too. Here we have a button.
It will be better. Let's make a separate component of the button. button.jsx rafc and here in the header, let's make a separate component of this button. And here we will receive children, all this is coming to you, if this is not coming, then leave it, you know how to receive props. Props props dot title will come here, I will tell you how our button came here and if we write only button inside the button, then this join us button will come, here we have written the button in the app dot JSX, we import the button in this way, button all right. So here in both the places the same button is coming, join us, join us. If I want to change the title inside it, then how will I do it?
I can send props here. I have sent the title here. You have to send in the key value pair. So I sent the title, hello. And here I can receive in the button. See, I am receiving props. So props will come in the format of an object. In the key value pair, title hello. So I can do that here. And I have told you many times. So all this you for this it is very easy props.title so here props.title is coming now it is coming in this but not in this why? because here in header we have not sent props alright so if props are not sent then we can do conditional rendering here but we will send it now we have not read conditional rendering here so title is equal to.
We have made the button separately and we have made the button and used it here as well. In the header component and in the app component, we have used the button. We have not done anything separately. This is our heading. From here to here. This is our paragraph. This is our button. So now it looks like this. And this in the middle, we will give space above and below it. Basically padding or give margin. From margin Y, we give 4 from left. So a little space will come from above and below. If you want a little more space, then give 7. A little more space will come. This looks beautiful. I want to increase the size of the button font a little. So from here I can pass the class name as a props. As a props, I can pass it. But if someone doesn't understand, then I can make a parent container here and increase the size here. Class name, I give the size of the.
If we had given the size of the parent, then the same would have been applied in the child. And if we change it to child, then the child one will be applied. This is normal, you have read it in CSS. Ok, so we gave it to the parent, then it will be applied to the child too. And the second way was that here we could pass the style as a props. So something like this is coming. So see which button was here. Here the button was our join watchlist. Ok, the title was the same in both, but again we change it. I told you to change it.
Let's take subscription, join subscription. OK, so this is something like this. It looks beautiful. We have actually made a very beautiful design. The best way to review creative assets. And here we have this brand etc. Great, great, great. OK, now let's make a footer and see. So should we put it in a separate component? Come, let's put it in a separate component. So here we give it a name.
We have copied the header and here we have made the footer component footer.jsx. Components are coming. If the components are not coming, then there will be a problem. I have told this in many lectures. So this is our footer and here we import the footer quickly and use the footer too. So this is our footer. Where is the footer from? Component slash footer.
This is our footer. But we don't need such footer. We need such footer. In which there are 5 layers. For this we can definitely make a grid. We were using flags here, now we will use grid. We need 5 grids here. This is the second grid. We need flex-direction-column. We were taking it in row first. Now we need it vertically. We will do flex-column. Flex-column means flex-direction-column. It was flex-direction-row-column. I am doing flex-direction-column. It will look like this. I need 4 of them. I am going to change the name of the company.
It was cut in the middle because of the phone. I use external software in the phone. I forgot to turn on the aeroplane mode when the call comes. For now, I don't know, it was cut from here, it was just a call. So I have done so much here, see this, I will remove it now. So I have given a heading here. I made the footer as the header was. I gave a heading in the middle here, I gave it a little flex and a gap one, so now it looks like this. This is something like this. And this is coming here. And this brand one is here. Where did it go? Brand one. Brand one is here. And then here is one. And we have made five grid. Grid columns five. So one element is done. One element is done.
Will be one more. So this is our fifth one. No, five had already been done, one extra came. So this is one, two, three, four, yes, five, five, okay, it's done. So this is our made some header in this way. And there is a line below, so you can take a line and put all these things here. Should I put it and show it? Now I put it quickly, see this. So this is our grid, this is the header. I will close this. This is our grid. We need a line below this. So I will make a div and you must be knowing how to make a line in CSS.
So this is looking something like this. It is looking very beautiful. And here we will give a little padding bottom of five. So this will also come a little padding from here. And not even five. Let's give eight. So this is a little bit of padding. Now what we have to do below this, we will make another div below it. Where a paragraph will come. And some people will come here. Okay, some people will come here. Now for the time being, instead of people, I write some letters. T and X. So this will come in our way. And the same here, this two thousand twenty five, this, this, that, that. What I do here simply, I write lorem. You can write whatever you want to write. Let's see something like this is coming here. And actually, we have to give the maximum weight of 60rem in this too. Class name, maximum weight 60rem.
We gave it in the header. So we gave it here too. So it will be a little consistent. And if we give margin auto, it will come in the middle. It has come in the middle. And we will give flags in it. So it will come in this way. And we will give justify between. So space will come in the middle. See this icon came here. And if you want to give space in the middle in the icon. So class name flags. And give gap here also of five. Here space came in the middle. And if you want to give class name in it. Like font bold. If you want to make it like icon then you can make it. Font bold and here also font bold.
Then what else did we have to make? We had to make a hero section, so we have made that too, obviously. So it looks something like this. I believe your tailwind css must have been practiced a little. If you are getting css, then tailwind css is nothing for you. But if you are not getting css, then you.
To do font size, font bold, etc. of text, there is only one property here, text. We will write color by giving a dash in it, the background color will change. We will write width by giving a dash, the font size will change. I will write center and left right by giving dash and alignment will change. If you want to give color in BG, then you will write color by giving BG dash and color will change. Then I have not told media query yet, let's see media query a little bit.
If you want to make it smaller and more responsive, then you can make it more responsive here. And this is also getting a little damaged, so you will have to see this too, maybe this is getting damaged above the header. So let's see the header first. So this will be the hide in the header. After a few pixels, this will be the hide and a button should come here. So, bring that button from logic. Rest, we will learn that logic further. How to do conditional rendering. So, leave it for now. For now, we just hide it. You must have seen it in the application when it was small. This menu is hidden. And here comes a menu icon. It comes from the side when you click the icon. So, for now, let's hide it. We will perform that logic when we read conditional rendering. So, let's hide it after 770 pixels. So, let's come to the header. Where is our header? This is our header. This is our menu. keep it hidden up to 770 pixels. Display hidden.
Basically, I did display none. So this is something like this. And this is coming in a sticky way. So I will also give padding x1rem in the header. So now it will come a little like this. See how easy it is to be responsive with tailwind. If you want to keep it small, then after 340 or 3400 pixels, make it grid column 1. Where did our footer go? So here we will put one more media query. After a maximum of 400 pixels, we will make the grid column 1 here.
Can increase the gap here. We should have given a gap. We did not give a gap, we should have given a gap. So, we also give a gap when it is responsive. Like here the maximum is being responsive after 770 pixels. So here we also give a gap of 2rem and see how it is looking. So there is no gap in the middle, we do not need a gap here. When it is small, we need a gap before 770 pixels. See the gap in the middle, there was no gap before. If you look carefully, then I will remove this. Now see there was no gap here. After the portfolio, it was coming immediately. There was no gap. And now if we give this here, if we give a gap up to 770 pixels, then it will be small and the gap will be maintained here.
After max of 770px do flex column so it will come in column see this did not come in column flex column ok it is in column ok what am I doing in column actually one minute one minute wait this is in column only this was not done in the last this one was done here maximum of seven seventy pixel. We will do the column. So now see it just came down. If you want to give a gap, then you can also give a gap. So now it is coming perfect. Okay and here also we will give padding one rem. Padding one rem. So this is a little space. So now see it is looking perfect. Uh okay where is this from again? To make it small, this is a little So that's why it's happening. You can make its size a little smaller. How to make it smaller? So come to the hero section and write here maximum of five hundred pixels. I want to keep its size a little smaller. Let's make the text three pixels. So look at this, the text has become three pixels. So as soon as it is less than five hundred pixels, its text gets smaller.
And there is no padding in this either. Let's give padding in this as well. This is the whole hero section. So we will give padding to it. So a little padding will come in this too. It will look good. This is the padding that has come. And we will also make the size of this button a little smaller. After a maximum of 500 pixels. I mean to say that we are making it smaller. So according to making it smaller, I am saying later. If you look at the rest in actual, then your text from 0 to 500 pixels.
And, in Tailwind CSS, all the other properties have been written. If you know CSS, then it will be very easy for you. But, if you don't know CSS, then it will be very difficult for you. Because, I have done the same thing in CSS. In media query, what I had explained, that maximum width is this much, so, we apply media query in this way. Here, we do this, we do that. So, those who have done CSS, Tailwind CSS is nothing. It is CSS only. Okay, so I hope you understood Tailwind CSS. Rest, all the lectures that are going to come, in all.
