Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Elevating React Web Development with Gatsby

You're reading from   Elevating React Web Development with Gatsby Practical guide to building performant, accessible, and interactive web apps with React and Gatsby.js 4

Arrow left icon
Product type Paperback
Published in Jan 2022
Publisher Packt
ISBN-13 9781800209091
Length 314 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Samuel Larsen-Disney Samuel Larsen-Disney
Author Profile Icon Samuel Larsen-Disney
Samuel Larsen-Disney
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Part 1: Getting Started
2. Chapter 1: An Overview of Gatsby.js for the Uninitiated FREE CHAPTER 3. Chapter 2: Styling Choices and Creating Reusable Layouts 4. Chapter 3: Sourcing and Querying Data (from Anywhere!) 5. Chapter 4: Creating Reusable Templates 6. Chapter 5: Working with Images 7. Part 2: Going Live
8. Chapter 6: Improving Your Site's Search Engine Optimization 9. Chapter 7: Testing and Auditing Your Site 10. Chapter 8: Web Analytics and Performance Monitoring 11. Chapter 9: Deployment and Hosting 12. Part 3: Advanced Concepts
13. Chapter 10: Creating Gatsby Plugins 14. Chapter 11: Creating Authenticated Experiences 15. Chapter 12: Using Real-Time Data 16. Chapter 13: Internationalization and Localization 17. Other Books You May Enjoy

Styling with CSS

In this section, we will learn how to implement CSS styling into our Gatsby project.

There are two different methods to adding global CSS styling to our Gatsby site – creating a wrapper component or using gatsby-browser.js.

Creating a wrapper component

The idea behind a wrapper component is to wrap our page components in another component that brings common styles to the page:

  1. Create StyleWrapper.css in your components folder:
    html {
      background-color: #f9fafb;
      font-family: -apple-system, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif,
        "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI
        Symbol";
    }

    In the preceding code, we are defining a background color and a font family that all children of the HTML tag can inherit.

  2. Let's now add some h1 styles to this file:
    h1 {
      color: #2563eb;
      size: 6rem;
      font-weight: 800;
    }

    Here, we are adding the color, size, and weight of the largest heading...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image