Loading dynamic fonts in React MaterialUI

In our web application, each user experiences a unique style with colors, fonts, border widths, and more based on the Material UI JSON theme retrieved from the database upon loading the app.

The challenge lies in handling dynamic fonts. What approaches have been tested for dynamically loading the required font(s) based on the theme? Remember, one user may see a different font compared to another user.

For instance, user one could have this theme setting:

"fontFamily": "'Galaxie', sans-serif"

While user two might have this defined in their theme:

"fontFamily": "'Roboto', Arial, sans-serif"

Normally, you would use a CSS file or add a line of code in the HTML to load these fonts from the server. However, we aim for user-specific optimization where user one only downloads the Galaxie font, and user two only fetches the Roboto font.

Our current proposed solutions are:

  • Require all users to download all fonts (impractical at large scale)
  • Generate a CSS file that dynamically populates font definitions depending on user requests from the server

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

What is the best way to transmit error messages from the server to the client?

I am currently working on my express server and I have a query regarding how to efficiently communicate error messages to the client side. My goal is to display the error message both on the client console as well as on the server console, but I am uncerta ...

Preventing background style from taking precedence over backgroundColor style in React's inline styling

What causes background to take precedence over backgroundColor in React inline-style? In this scenario, the lack of a specified green background-color results in the background gradient with transparency transitioning into white rather than green within t ...

The compatibility of MUI installation with React 16 is currently not functioning

My React version is 16.1.3 and I am encountering difficulties trying to install the following two packages: @mui/material @mui/x-data-grid I have attempted to install all versions, from the lowest to the highest, but unfortunately none seem to work. In m ...

When the ajax response comes in, my javascript code seems to suddenly stop

After sending a POST request, my JavaScript suddenly stops working for some unknown reason. Here's the situation: I visit my webpage, fill out the form, and then click 'Click me' : Upon clicking OK in the alert popup, I see the expected ou ...

Having trouble integrating MaterialUI Datepicker, Dayjs, useFormik, and Yup

Currently, I am facing a recurring issue with the Material UI Date picker in conjunction with day js. The problem arises when I select a date on the calendar for the first time, it updates correctly in the text field but fails to work thereafter. Additiona ...

Encountering a problem with the Material UI Autocomplete component when trying to implement

I am trying to integrate a Material UI autocomplete component with a checkbox component. Is there a way to have the checkbox get checked only when a user selects an option from the autocomplete? You can check out my component through the following links: ...

Matching patterns in Textfields using Material UI

Hey there! I'm a newcomer to material ui and I'm trying to set up a textField that only allows numbers. I attempted using "pattern" but it's not working, and also tried setting the type to number which worked, but I really need it to work wi ...

Styling child elements in Angular using css from its parent element

I have a question: Regarding the structure below <component-parent> <first-child> <second-child> <third-child></third-child> </second-child> </first-child> </component-parent> Now I want t ...

Steps for changing the direction of a dropdown menu to the left instead of the right

I'm having a bit of an issue with my inbox setup. I have a dropdown for it, but the dropdown is appearing off to the right and since it's at the end of my top navbar, it's not very visible. Here is the CSS code for the inbox: .notification ...

Issue with automatic compiling in Sublime 2 for less2css

Whenever I try to save my style.less file, the automatic compilation doesn't happen. Is there a mistake in how I've set it up? Here's what is currently in my ox.sublime-project file: { "folders": [ { ...

Choose just one column within an HTML table

Is there a way to easily select the text of a single column from an HTML table using just the mouse pointer? Imagine you have a table that looks something like this: https://i.sstatic.net/n3lZR.png When trying to select only the text in the Lastname col ...

Tips for sending files from react to my .net server

Can someone help me with uploading images to my server using React? This is what my controller looks like so far: [Authorize] public object UploadAvatar() { var file = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Requ ...

Having trouble with Next.js, authLink, httpLink, and GraphQL subscription integration

Struggling to make this work as expected. After some research, I discovered that nextjs/ssr has compatibility issues with subscriptions and it's important to verify the existence of process.browser. However, I am facing challenges in integrating my au ...

Issue with setting a background image to a div in Next.js: not functioning as expected

I haven't used Next.js before and I'm having trouble setting a background image for a specific div. I have a folder named public in the root directory where I've placed the file art-thing.jpg. My styles.css is also in the root directory, whi ...

Error in scrolling previews detected in Jssor horizontal template maker

I've been working with Jssor Slider Maker and I'm using the vertical preview template that features two columns on the left side and a maximized image on the right side. After pulling the code from the developers pack, it includes scripts, CSS an ...

Enhancing the appearance of dropdown menus for WooCommerce Variable products with custom CSS styling

I currently have a Wordpress website with WooCommerce and several variable products. Each product's variation has a dropdown menu that displays different options when clicked. My main concern is how to customize the appearance of these dropdown menus ...

What is the best way to display or conceal an array object using a toggle switch?

I'm trying to implement a show/hide functionality for descriptions when toggling the switch. Additionally, I want the switch to be initially checked and only show the description of each respective result. However, my current code is displaying all de ...

What could be causing the undefined value for this.props.username in React-Redux?

I'm facing an issue when trying to access this.props.username in the following code snippet: loginClick = (event) => { event.preventDefault(); console.log('Login submit click, props.username: ' + this.props.username); this.props.lo ...

individual elements displayed sequentially within the same block with variable naming

My code caters to both mobile and desktop versions, with the same elements in the FORM. However, only one block of code is visible at a time depending on the screen size, with one set to display: none. <div id="desktop"> <div id="content"> ...

What could be the reason for the absence of the CSS destination folder being generated by

My colleague has the exact same code and can run gulp without any issues, but I'm struggling to compile the css files using Gulp. Gulp isn't creating the css destination file or the css files themselves. However, it works perfectly fine for build ...