
Join the Conversation!
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
"Please login to view comments"
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
By logging in, you'll unlock full access to this and other free tutorials on JSM Pro.
Why? Logging in lets us personalize your learning experience, track your progress, and keep you in the loop with new workshops, coding tips, and platform updates.
You'll also be the first to know about upcoming launches, events, and exclusive discounts.
No spam—just helpful content to level up your skills.
If that sounds fair, go ahead and log in to continue →
Enter your name and email to get instant access
##Looks like we found a thief monkey By the way, I liked the trick how you reached till here. You have a good sense of humor. You will improve a lot if you join our course with this passion.
var
(function-scoped, outdated)let
(block-scoped, modern and recommended)const
(block-scoped, cannot be reassigned)_
, or $
let let = 5;
is invalid)myVar
and myvar
are different)string
, number
, boolean
, null
, undefined
, bigint
, symbol
Objects
, Arrays
, Functions
Subscribing gives you access to a brief, insightful summary of each lecture to stay on track.
00:00:00Â So how can we apply styles in React?
00:00:03Â Or maybe I should rephrase.
00:00:05Â Is there any kind of styling we can't use with React.js?
00:00:09Â Inline styles, CSS, Tailwind CSS, Bootstrap, Material UI, AntUI, SAS, CSS in JS, CSS modules, you name it.
00:00:19Â You can choose any approach to style your React apps.
00:00:22Â So let's try a couple of these styling ways in our app.
00:00:26Â First of all, head over to index.css and remove all styles from here.
00:00:31Â This is one way of styling where you write styles in a separate CSS files and then you import them into your component.
00:00:38Â We've imported this index.css file within our main .jsx.
00:00:43Â Let's start by applying some styles to this app.
00:00:45Â I'll start by targeting all the elements and set some styles that you typically do at the start of every single application,
00:00:52Â such as box sizing set to border box, margin set to zero, and padding set to zero.
00:01:00Â This will reset those styles for all the elements on the screen.
00:01:04Â Next, we can target the body element and give it some padding, like 40 pixels should be enough.
00:01:10Â Oh, and I almost thought that I was writing CSS in JS, so I automatically made it a string, but that's not necessary in regular styling.
00:01:18Â We can also change the background color to something like hash 151515. Let's also change the font family to something like Franklin.
00:01:31Â Gothic medium, or if we don't have that, we can just do Arial.
00:01:36Â And finally, we need to style the H2 element by changing its color to something like hash F3, F3, F3, giving it a text align of center,
00:01:48Â as well as a margin bottom of about 30 pixels.
00:01:52Â And finally, a font size of 48 pixels.
00:01:56Â There we go.
00:01:57Â Now I can zoom out a bit.
00:01:59Â and we can see everything more clearly.
00:02:01Â We just applied some styles directly to HTML elements without having to manually select them right here.
00:02:07Â But if we want to be a bit more specific, then we can use class names.
00:02:11Â So let me remove this first H2, and let's remove some of these props as we're not using them anyway.
00:02:17Â And now we can give this div that's wrapping these three cards a class name equal to card-container.
00:02:26Â Notice that unlike styling HTML, you don't have to say class name or lowercase.
00:02:31Â In React, it actually has to be uppercase and in class name.
00:02:35Â Now you can head back over to index.css and style that class name by saying dot card container.
00:02:43Â And then you can give it a display flex, flex wrap of wrap, justify content of center, as well as a max width of something like 1024 pixels.
00:02:56Â This will make it look good on all different devices.
00:02:58Â I'll also give it a margin of zero and then auto.
00:03:02Â And naturally, if you applied an ID to this div, you would be able to style it by saying hash and then the name of the ID.
00:03:10Â Now that you know how we can use external style sheets to style our React components, let me also teach you how we can do some inline styles.
00:03:17Â We can do it on this card component by giving this div a style property and an object.
00:03:23Â And then here you can define styles within JavaScript by saying, for example, border is one pixel solid.
00:03:31Â And then we can do hash 4B5362.
00:03:34Â And now each one has a border.
00:03:38Â We can give it some additional padding of maybe 20 pixels.
00:03:42Â Let's give it a margin of 10 pixels as well.
00:03:45Â A background color.
00:03:47Â of hash 31363f.
00:03:51Â And notice how if you're using inline styles within JavaScript, you cannot say background dash color.
00:03:56Â It's actually using camel case, background color.
00:03:59Â Let's also give it a border radius of something like 10 pixels.
00:04:04Â And let's also give it a min height of about 100 pixels.
00:04:07Â Now, what would happen if we mixed and match both the styles from the external style sheet and internal ones?
00:04:14Â Let's add a class name right here, equal to something like a card.
00:04:19Â If you now head back over to index.css and define the .card class name, and give it something like a border of 2 pixel solid red.
00:04:29Â Oh, again, I'm using string signs here where I don't need to.
00:04:32Â You can notice that the color didn't change.
00:04:35Â That means that inline styles have the preference over all the other CSS stylings.
00:04:39Â So, do remember that.
00:04:41Â But it's always better to stick with one way of styling anyway.
00:04:45Â And in today's world, Tailwind CSS is the way to go.
00:04:48Â It's the preferred way of styling apps of any kind.
00:04:52Â So in this tutorial, later on, once we actually start building your movie application, you'll use the most popular and most in-demand way of styling applications
00:05:02Â through the latest version of Tailwind CSS, version 4.0, which was released exactly at the date of publishing this video.
00:05:10Â So you know that with JSM, you're always getting the latest information.
00:05:14Â Now let's quickly fix up our styles by heading over to the Index CSS and removing this margin bottom from the H2.
00:05:21Â We don't need it.
00:05:22Â And now all of our cards are looking good.
00:05:24Â But remember, I already told you that it's always best to use one way of styling.
00:05:28Â So in this case, I will remove these inline styles and I'll move them over to our external style sheet.
00:05:35Â So let me copy all of this.
00:05:37Â and exchange it for a class name of card.
00:05:41Â Then we can head over into our index.css and paste all of those styles here, but you'll have to change it to use lowercase letters and dashes in between.
00:05:51Â So border radius, background color, and min height.
00:05:56Â And at the end, you'll have to add a semicolon.
00:05:59Â And of course remove all the string signs.
00:06:01Â We don't need that in native CSS.
00:06:04Â So let me quickly do that.
00:06:06Â And we're good.
00:06:07Â Everything still works as before.
00:06:09Â And with that, we are ready to dive into.