Local font not applying styles in Tailwind CSS

I integrated the Gilroy font into my application, but I am facing issues with tailwindcss not being able to style the text properly. The font appears too thin in all elements such as paragraphs and headers.

Here is the file structure for reference: https://i.stack.imgur.com/T8OPH.png

Snippet from layout.tsx file:
import type { Metadata } from "next";
import localFont from "next/font/local";
import "./globals.css";

const gilroy = localFont({
  src: [
    {
      path: "./fonts/gilroy/Gilroy-Thin.ttf",
      weight: "100",
      style: "normal",
    },
    {
      path: "./fonts/gilroy/Gilroy-ThinItalic.ttf",
      weight: "100",
      style: "italic",
    },
    // More font configurations...

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Description",
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body className={gilroy.className}>{children}</body>
    </html>
  );
}

Answer №1

It is recommended to delete the tailwind.config.js file in order to avoid conflicts with the tailwind.config.ts file.

Additionally, ensure that the content property of the tailwind.config.ts file is set up correctly. The initial setup should resemble the following:

import type { Config } from "tailwindcss";

const config: Config = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./components/**/*.{js,ts,jsx,tsx,mdx}",
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};
export default config;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Combining multiple directories within a single express route with NextJS

I am currently working on a NextJS/Express project to develop a website for sharing articles. Within the pages directory, I have an article page nested under (pages/articles.js). My goal is to set up multiple subdirectories that will redirect to this tem ...

What are the best methods for saving extensive information in Next.js session storage or implementing session file storage?

I am looking to save user data in session. What is the best way to store large amounts of data in a session, similar to how it is done with express session file storage? ...

Getting around using Material-UI Icons

Is it possible to utilize a Material-UI Icon for navigation using React Router Dom? I attempted the following approach without success: <NavigateBeforeIcon path="/vehicles"></NavigateBeforeIcon> With buttons, I am able to use component={Link ...

Experimenting with Vuejs by testing a function that delivers a Promise upon the execution of the "Created" hook

In my Vuejs application, I have the following script written in Typescript: import { Foo, FooRepository } from "./foo"; import Vue from 'vue'; import Component from 'vue-class-component'; import { Promise } from "bluebird"; @Component ...

How to Include Data in the <Head> Tag Using Query Parameters with NextJS

I have a dilemma with my website pages that are using the getStaticProps method. I am trying to figure out how to dynamically add 'noindex' meta tag to pages that have a 'q' parameter in the URL. Unfortunately, this approach does not se ...

How come the icon doesn't update on the client side after being rendered on the server side?

Currently implementing a Daisyui theme switcher in my nextjs project. It's mostly working fine, but there are some issues I'm having trouble with. I've created a simple theme switch button: // Themeswitch.jsx 'use client'; impor ...

Utilize PrimeNG's async pipe for lazy loading data efficiently

I have a significant amount of data (400,000 records) that I need to display in a PrimeNG data table. In order to prevent browser crashes, I am looking to implement lazy loading functionality for the table which allows the data to be loaded gradually. The ...

Verifying the presence of an object in an array based on its value using TypeScript

Having the following dataset: roles = [ {roleId: "69801", role: "ADMIN"} {roleId: "69806", role: "SUPER_ADMIN"} {roleId: "69805", role: "RB"} {roleId: "69804", role: "PILOTE"} {roleId: "69808", role: "VENDEUR"} {roleId: "69807", role: "SUPER_RB"} ] The o ...

Guide to verifying a value within a JSON object in Ionic 2

Is there a way to check the value of "no_cover" in thumbnail[0] and replace it with asset/sss.jpg in order to display on the listpage? I have attempted to include <img src="{{item.LINKS.thumbnail[0]}}"> in Listpage.html, but it only shows the thumbna ...

Type inference in TypeScript with transitivity

Consider this code snippet for illustration: function foo(t: "number"): number function foo(t: "string"): string function foo(t: "boolean"): boolean function foo(t: "number" | "string ...

Unpacking the information in React

My goal is to destructure coinsData so I can access the id globally and iterate through the data elsewhere. However, I am facing an issue with TypeScript on exporting CoinProvider: Type '({ children }: { children?: ReactNode; }) => void' is no ...

Utilize styled-components in next.js to import and resize .svg files seamlessly

I have been attempting to import .svg files into my next.js project, but I have not had any success. I tried importing the .svg files the same way as in my React project by creating a typing.d.ts file and importing the svg as a component. However, it did ...

Utilize TypeScript in creating a Chrome extension to fetch elements by their ID

I'm currently working on a Chrome extension using Angular and Typescript, and I have encountered an issue with accessing the document element by its id from the active tab. While this works perfectly fine in JavaScript, I am facing difficulties in ach ...

Populate input fields in HTML using Angular 4

Within my angular 4 project, I am facing the challenge of setting a value in an input field and in a MatSelect without relying on any binding. Here is the HTML structure: <div class="row search-component"> <div class="col-md-5 no-padding-rig ...

`Getting the hosting URL for a CSS file in NextJs``

I faced a challenge where I needed to host a CSS file and load it into an iFrame on the page. Previously, I had successfully used file-loader in a Preact project for this purpose. However, when I tried to implement it in NextJs, I encountered issues. The C ...

After updating the data, the React Material UI Grid Item fails to render

I am encountering an issue where the code fails to render grid items when there is a change in props.data from the top component. import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Grid from '@ ...

In TypeScript, the error "Property does not exist on type 'any[]'" indicates that a specific property is not recognized on

Working on my project using Textscript in Next Js has been mostly smooth sailing, but I keep encountering warnings in my script that say 'Property does not exist on type any[ ]'. The red line under the name, image, and price properties is a sourc ...

Utilizing the Laravel back-end API within the getServerSideProps() function in Next.js

Currently, my setup involves using next js for the front-end and laravel for the back-end. I am attempting to make an API call to the back-end (laravel) from the getServerSideProps() method as demonstrated below: export async function getServerSideProps(co ...

Pass data that has been asynchronously resolved from the parent component to the child component using props in Vue

Main component: <template> <div> <Nav :data="data" /> </div> </template> <script lang="ts"> // ... imports removed for clarity @Component({ components: { Nav: () => import('@/components/Nav.vue&ap ...

The type of the element is implicitly set to 'any' because the expression 'keyof IMyObj' cannot be used to index the type

Trying to avoid specifying types in TypeScript and setting a value by accessing its key is causing a TypeScript error. Despite looking at multiple StackOverflow posts, I couldn't find a solution. I encountered a similar issue with my code and tried r ...