Chakra UI: Trouble with applying a personalized font from Fontsource

I recently added a new font from Fontsource called Girassol () by running the following command:

npm install @fontsource/girassol

In addition, I have a file named theme.ts with the following content:

import { extendTheme } from "@chakra-ui/react";

const customTheme = extendTheme({
  components: {
    Text: {
      variants: {
        logo: {
          bgGradient: "linear-gradient(45deg, #20b2aa, #cc0000)",
          textFillColor: "transparent",
          bgClip: "text",
          fontFamily: "Girassol, sans-serif",
          fontWeight: "800",
          as: "span"
        },
      },
    },
  },
});

export default customTheme;

Next, in my file Home.tsx, the code looks like this:

import { Text } from "@chakra-ui/react";
import "@fontsource/girassol"

export function Home() {
  return (
  <Text variant={"logo"} as={"span"}>
    Some Text
  </Text>
  );
}

However, despite my efforts, I'm unable to apply the custom font I downloaded. Whenever I switch the font in my theme.ts file to something more common such as Arial or Times New Roman, the change is reflected. I seem to be struggling to make the custom font work properly. Can anyone pinpoint where I might have made a mistake?

Thank you,

Carolina

Answer №1

Success!

I successfully resolved the issue by adding

import "@fontsource/girassol"
to my main.tsx file, where I import my ChakraProvider.

After making this change, I encountered the same error mentioned in this helpful post that explains the error message.

Instead of following the solution provided in the post, I realized that the @fontsource folder was not in the correct location. It should have been within the node_modules folder of my local repository, but it was mistakenly placed in another node_modules folder outside of my repository. Therefore, I relocated the folder to the right directory and solved the problem!

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

ajaxStop and ajaxStart not functioning as expected

Currently working on a project to create a Wikipedia viewer, and running into an issue with the following code snippet: $(document).ready(function() { $(document).on('click', '#search_button', function() { ...

Issues with syntax in AJAX programming can be a significant road

I have a function linked to an onclick button event. This function sends data via ajax to another php file. Everything was working smoothly until I tried to add an IF statement to the 'success' section, which would receive true or false from an e ...

Adjust the flexslider to transition to a new slide when hovering over the thumbnails

I have a flexslider with thumbnails like this ; https://i.stack.imgur.com/9bfC2.jpg I am looking to change the slide when the user hovers over the thumbnails. How can I achieve this functionality? Here is the jQuery code I am currently using to set up th ...

Is there a way to deactivate multiple time periods in the MUI Time Picker?

Recently, I have been working on implementing a Time Picker feature with two boxes: [startTime] and [endTime]. The objective is to allow the time picker to select only available times based on predefined data: let times = [ { startTime: "01:00", en ...

What is the best way to create a transparent sticky header that blends with the background while still maintaining visibility over images and text?

On my web page, the background features a radial gradient but the content extends beyond the viewport, causing the center of the gradient to not align with the center of the screen, producing the desired effect. However, I'm facing an issue with a sti ...

How can you incorporate AJAX to add a paragraph element to your HTML document?

I have encountered an issue with two files in my project. The first file is an HTML document, while the second file is a PHP file called ajax_access_database.php. Originally, I intended for the PHP file to access a database, but complications arose, leadin ...

transform data into JSON format and transmit using jquery ajax

I have one object: var myobject = {first: 1, second: {test: 90}, third: [10, 20]}; and I need to convert it into a JSON string using jQuery ajax. Can someone please advise on how to achieve this? (I tried using JSON.stringify(), but it didn't work ...

What is the process for deleting an event in Vue?

My Vue instance currently includes the following code: async mounted () { document.addEventListener('paste', this.onPasteEvent) }, beforeDestroy () { document.removeEventListener('paste', this.onPasteEvent) }, methods: { onPasteEv ...

Can anyone please guide me on how to extract the IP address of a specific individual using Node.js?

There's an individual running some kind of exploit scanner on my server. I'm receiving strange requests like: IP ADDRESS: ::ffff:127.0.0.1 www-0 (out): POST /cgi-bin/php5?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64 ...

Only implement $(document).on(...) for every JQuery request

As someone new to Jquery, I'm facing challenges in grasping its functionality. Specifically, my struggle lies in setting up an event listener on an i element with the class of .dataPickerIcon, which should respond to a click by inserting more HTML usi ...

Dealing with Errors - Utilizing Observable.forkJoin with multiple Observable instances in an Angular2 application

One of my Angular applications has two objects, Observable<Object1[]> and Observable<Object2[]>, that call different APIs in the resolver: resolve(): Observable<[Array<Object1>, Array<Object2>]> { const object1 = this.boo ...

The Value of Kendo Data

Below is my current kendo code snippet: <script> $("#dropdowntest").kendoDropDownList({ optionLabel: "Select N#", dataTextField: "NNumber", dataValueField: "AircraftID", index: 0, ...

Firefox seems to handle webpages smoothly, whereas IE struggles to display them properly

Check out the code snippet below: self.xmlHttpReq = new XMLHttpRequest(); self.xmlHttpReq.onreadystatechange = function() { if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) { xmlDoc = self.xmlHttpReq.response ...

A step-by-step guide for updating a minor version of Angular with Angular CLI

I've been searching online for the answer to this straightforward question, but can't seem to find it anywhere... In my angular 4 project (made with angular cli), I want to utilize the newly introduced http interceptors in version 4.3. Could so ...

Integrating the feature of pasting Excel data directly into a Django form

My current Django form consists of a table with N rows and 12 columns of textboxes, allowing users to fill out the form one textbox at a time: [________][________][________][________][________][________][________][________][________][________][________][_ ...

"Utilizing aws-sdk in a TSX file within a React project: a step-by

When working on a project using TypeScript (tsx) for React, I encountered an issue with uploading images to the server using aws-sdk to communicate with Amazon S3. To resolve this, I made sure to install aws-sdk via npm and typings. UploadFile.tsx import ...

JavaScript server variable

How can I access a server-side asp.net variable in JavaScript? I'm trying to achieve something like this: function setBookmark(val) { document.getElementById('<%# hBookmark.ClientID %>').value=val; } Is there any way to accomplis ...

WebPack integration with Wordpress encounters an issue due to ReactJS Code Splitting while trying to load Bootstrap

Currently, I have set up a WebPack configuration that enables the direct injection of ReactJS into a website. This process compiles all the React code into a single index.js file, but I am facing an issue with its size. To address this, I am attempting to ...

Building a dynamic AngularJS module on-the-fly: A step-by-step guide

I am trying to dynamically create AngularJS modules, and here is what I have so far: <section class="panel portlet-item" id="crashpanel"></section> <script type="text/javascript"> var angularApp = angular.module("Crashpanel", []); angula ...

Use ng-click to enable specific actions only on the element in which it is placed

Using ng-repeat, I have created a series of elements... <div class="form-block" ng-repeat="form in formblock | filter:dateFilter"> <div ng-click="showResults()" ng-if="repeat == true" class="drop">{{ form.form_name }} <span class="care ...