question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How add custom font family?

See original GitHub issue

I installed a font using expo in this way. It works

<Text style={{ fontFamily: 'Inter_900Black'  }}>Inter Black</Text>

Now I updated tailwind.config.js in this way:

module.exports = {
  content: [
    "./**/*.{ts,tsx}",
  ],
  theme: {
    extend: {
      fontFamily: {
        'inter-black': ['Inter_900Black'],
      },
    },
  },
  plugins: [],
  corePlugins: require('tailwind-rn/unsupported-core-plugins'),
}

So I updated the style. But I’m getting the error: Unsupported Tailwind class: "inter-black"

<Text style={tailwind('inter-black') }>
  Inter Black
</Text>

Also, I tried in this way, but same message:

module.exports = {
  content: [
    "./**/*.{ts,tsx}",
  ],
  theme: {
    fontFamily: {
      'inter-light': ['Inter_300Light'],
      'inter-black': ['Inter_900Black'],
    },
    extend: {},
  },
  plugins: [],
  corePlugins: require('tailwind-rn/unsupported-core-plugins'),
}

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
erquhartcommented, May 12, 2022

Spent more time than I care to admit on this, but it turns out we’re just forgetting to prefix font-, eg., font-inter-light. Which, to be fair, could be more explicitly called out in the tailwind css docs.

module.exports = {
  theme: {
    extend: {
      fontFamily: {
        'sans': ['Arial'], // outputs "font-sans"
        'inter-light': ['Inter_300Light'], // outputs "font-inter-light"
      },
    },
  },
}

Works fine in tailwind-rn 4.2.0, works with or without theme extension.

0reactions
erquhartcommented, Jul 22, 2022

@tommoholmes can you share a code snippet where you’re actually using the font?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Load and Use Custom Fonts with CSS | DigitalOcean
The most performant way to customize fonts is to use fonts already ... In the body selector, add a font-family property, and make...
Read more >
The Easy Way to Add Fonts to Your Website (Including ...
How to add custom fonts to your website using @font-face · Step 1: Download the font · Step 2: Create a WebFont Kit...
Read more >
Using custom fonts using CSS? - Stack Overflow
Generically, you can use a custom font using @font-face in your CSS. Here's a very basic example: @font-face { font-family: 'YourFontName'; ...
Read more >
CSS @font-face Rule - W3Schools
In the @font-face rule you must first define a name for the font (e.g. myFirstFont), and then point to the font file. To...
Read more >
Use a custom font - Flutter documentation
You have two options for how to apply fonts to text: as the default font or only within specific widgets. To use a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found