How to Define Global Styles in a React App
Get the project source code below, and follow along with the lesson material.
Download Project Source CodeTo set up the project on your local machine, please follow the directions provided in the README.md
file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.
This lesson preview is part of the Fullstack React with TypeScript Masterclass course and can be unlocked immediately with a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to Fullstack React with TypeScript Masterclass with a single-time purchase.

[00:00 - 00:10] Before we start writing the new code, let's remove the files that we are not going to use. Go to the SRC folder and remove logo_svg, app_css and app_test_tsx.
[00:11 - 00:25] Now open SRC app_tsx and change the default expert. Remove the expert default app to the named expert. Expert app. Remove the imports and the layout. For now we'll just return now.
[00:26 - 00:35] Now go to index_tsx and change the import here. Impert app from app. If you use VS Code, configure it to use workspace_taps cript version.
[00:36 - 01:02] Otherwise, if your global type_type script version is older than 4.1, you will get an error that React refers to an UMD global, but the current file is a module. Here is a relevant stock overflow answer. You can find the link in the text version attached to this video lesson. To select the TypeScript version, open the command palette, choose the select TypeScript version command and choose the VS Code version. Add global styles.
[01:03 - 01:31] Now let's define the styles to apply to the whole application. On the top level, on HTML, we'll need to define boxizing border box and we'll also add it to all the elements. This directive tells the browser to include padding and border elements in its width and height calculations. It makes it much easier to layout your components. We also make the HTML body and root elements to take the whole height of the screen vertically.