React Native Tutorial #18 - Global Styles
Key Takeaways
Applies global styles to components in React Native
Full Transcript
okay let my friends so in the last video I showed you how we could use a custom fonts and we're now using that font right here inside the home components for the title text which is this and we can see that on the screen so this all works now say I wanted to use this font family and this title text style on each of these text components right here in each different component about and review details and home then that would mean copying this style stuff and pasting it here and here and anywhere else that we wanted to use it now to me that stinks of code duplication that we don't really need to do and when we come to update this in the future if we change the title text styles we'd have to change it in every place we'd copied it to so it would be better if we had one central place where we declare a lot of different global styles then we can tap into those from any component and use them rather than just duplicating our code over and over again in different components so that's what we're gonna do now we're gonna create some kind of global style sheet if you like it's not really a style sheet but you know what I mean one of these which is global and then we can import that into any component that needs it and use those Styles so let us first of all go to the root directory down here and create a new folder and I'm gonna call this style so you don't have to store it in a styles folder I'm just doing this to keep everything organized now in here I'm gonna create a new file and I'm gonna call this global dot J s so this global GS file is going to contain all of the different styles that we'll use in different components so we first of all need to import style sheet because we're gonna construct this the same way we'd construct this thing right here so let's import first of all style sheet from react - native now we still need to create a style sheet in exactly the same way so in fact I'm just gonna copy this and I'm gonna paste it over here and we have now our container and we have our title text now I'm not going to call these styles I'm going to call them global styles like this and I'm going to export this as well so export Const global styles which is equal to stylesheet creates and then these are going to be the global styles so the title text right here is font family you need to bold the font size is 18 I'm also going to apply a color property to this so color oops if I can spell it is going to be 3 3 3 which is a deepest gray now we also have the container we use that in several different components so it makes sense to have this inside the global stars as well the padding I'm going to reduce to 20 pixels and then I'm also going to apply a flex property to this as well of once so that all the time our container views are taking up all the available space on the screen so there's two global styles I'm gonna do one more and that is going to be for a paragraph text so I'm going to call this paragraph and inside I'm gonna say margin vertical is going to be 8 pixels and then also the line height is going to be 20 so if we have any paragraph text like an article or the text on the about screen then we can use this paragraph style right here so we have those styles now and we can just import them wherever we need them so I could go now to the home screen over here and import this at the top first of all so import and it's going to be global styles from and it's dot dot come out of the current folder which is the screens folder then forward slash and we want to go into the Styles folder forward slash global okay so we've imported that and that now means we can use global Styles which is this constant right here so instead of saying style container I could say global Styles dot container and instead of style title text global Styles title text and I could delete these styles down here because we don't need them in this component anymore so if I save this and it refreshes over here on the right hopefully it should look exactly the same and it does this works awesome so let's do the same thing now inside the other components let's go to about and paste in the import this we can change to global styles container and I can delete this thing right here we could apply the title text to this as well but we'll do that later when we come to the about screen and I'm going to go to the review details again I can paste in the export or the import rather and then change this to global styles like so and remove this now at the minute we're not rendering any of these different components but you could do if you wanted to you could go to app KS and replace the home component we'd add about or review details and test this but believe me it is going to work we don't need to test that all we've done is changed the local styles were created right here for the global styles we've created over here we've imported those and we're using those instead and that makes more sense to me because now if we change these we can just change them in one single place and we can use them in any component or screen that we want to
Original Description
Hey gang, in this React Native tutorial we'll apply some global styles to our components in an external "styleseet".
----------------------------------------
🐱💻 🐱💻 Course Links:
Course files - https://github.com/iamshaunjp/react-native-tutorial
🐱💻 🐱💻 Other Related Courses:
+ Complete React Tutorial - https://www.youtube.com/watch?v=OxIDLw0M-m0&list=PL4cUxeGkcC9ij8CfkAY2RAGb-tmkNwQHG
+ React Hooks & Context Tutorial - https://www.youtube.com/watch?v=6RhOzQciVwI&list=PL4cUxeGkcC9hNokByJilPg5g9m2APUePI
+ Modern JavaScript Tutorial - https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Net Ninja · Net Ninja · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
Related AI Lessons
⚡
⚡
⚡
⚡
Had my Frontend Developer interview with Capgemini (Application Developer) today, and I wanted to…
Medium · JavaScript
10 Frontend Developer Tools to Boost Productivity in 2026
Medium · Programming
10 Frontend Developer Tools to Boost Productivity in 2026
Medium · JavaScript
The US Frontend Engineer Market in 2026: A Data-Driven Reality Check (and the Bias That Stops Us Seeing It)
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI