Quiz-PDF/Documentation/docs/NEW/Row III/SC Gitea.md

1.5 MiB

How to Set Up Fonts in FastPocket Using Tailwind

Setting up fonts in FastPocket can be a straightforward process if you follow a few key steps. This guide will walk you through how to configure fonts using the Tailwind config file and layout file, with a focus on using Google Fonts.

Click to watch the video

Choosing a Font

To start, you'll need to choose a font from Google Fonts. Visit fonts.google.com to browse the available fonts. You might want to select a font that is trending, new, or simply one that appeals to your design needs. Note that not all fonts may be available immediately.

Choosing a font - 19 Browsing fonts - 23 Unavailable font example - 37

Setting Variables in Tailwind Config

Once you've selected your font, you need to set the font variables in the Tailwind config file. For example, you might choose Roboto for your heading font and Indie Flower for your body font.

module.exports = {
  theme: {
    extend: {
      fontFamily: {
        heading: ['Roboto', 'sans-serif'],
        body: ['Indie Flower', 'cursive'],
      },
    },
  },
}

Setting variables in Tailwind config - 52

Swapping Fonts

If you decide to swap the fonts for body and heading, you can do so easily. For instance, if you want Roboto as your body font and Indie Flower as your heading font, update the Tailwind config accordingly.

module.exports = {
  theme: {
    extend: {
      fontFamily: {
        heading: ['Indie Flower', 'cursive'],
        body: ['Roboto', 'sans-serif'],
      },
    },
  },
}

Swapping fonts - 67 Updated Tailwind config - 75

Accessing Fonts by Font Family

In your layout file, you can access the fonts by their font family. For example, if you have set up Roboto as your body font, you can use it like this:

<div class="font-body">
  <!-- Your content here -->
</div>

Accessing fonts by font family - 94 Example of font body - 97

Trying Different Fonts

You can experiment with different fonts to see what works best for your project. For example, if you want to try Medi One but find it's not available, you can search for another font like Mrs Shepherds.

Trying different fonts - 113 Example of unavailable font - 124 Using Mrs Shepherds - 136

Ensure you set the correct weight for the font. For example, if Mrs Shepherds requires a weight of 400, set it accordingly in your Tailwind config.

module.exports = {
  theme: {
    extend: {
      fontFamily: {
        body: ['Mrs Shepherds', 'cursive'],
      },
      fontWeight: {
        body: 400,
      },
    },
  },
}

Setting font weight - 147 Updated font - 152

Conclusion

Setting up fonts in FastPocket using Tailwind is a simple process once you know the steps. Choose your font from Google Fonts, set the variables in your Tailwind config, and access the fonts by their font family in your layout file. Don't hesitate to experiment with different fonts to find the perfect match for your project. Happy designing!

Final result - 158