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.

Unsupported Tailwind class

See original GitHub issue

Hey! I’m currently starting up a new project using tailwind-rn, react-native and expo, however I’m facing a bit of a strange issue.

See, I’ve followed the setup guide to the letter, and I managed to get the library somewhat working, but on a lot of classes, it seems that it just doesn’t work (whether i use build:tailwind or dev:tailwind).

Looking at the tailwind.json and the tailwind.css (links attached), you can see a few classes being generated. However, I have no idea where these are coming from. For example, I’m not using border-red-500 or mb-1 anywhere yet, which makes me wonder why on earth would these classes get generated in the first place.

Taking a look at my tailwind.config.js, it would seem that everything is fine.

module.exports = {
  content: ['./src/**/*.{tsx,ts)'],
  theme: {
    extend: {
      colors: {
        primary: {
          50: '#F0F6FF',
          100: '#DBEAFF',
          200: '#B8D5FF',
          300: '#85B8FF',
          400: '#388BFF',
          500: '#004EBF',
          600: '#0046A8',
          700: '#004099',
          800: '#003580',
          900: '#002457'
        }
      },
      fontSize: {
        '5xl': '2.5rem'
      }
    }
  },
  plugins: [],
  corePlugins: { transform: false, translate: false, boxShadow: false }
};

The classes that are almost “randomly” generated in the tailwind.json/css are perfectly usable, such as text-red-500, but not the text-4xl that is currently being applied to the same <Text>: image

Here is also a link to my package.json.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
kxxolingcommented, Feb 11, 2022

Same issue here. I’ve created a fresh new project and encountered the same issue.

This is my App.tsx:

import {
  Colors,
  DebugInstructions,
  Header,
  LearnMoreLinks,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import {
  SafeAreaView,
  ScrollView,
  StatusBar,
  StyleSheet,
  Text,
  View,
  useColorScheme,
} from 'react-native';
import {TailwindProvider, useTailwind} from 'tailwind-rn';

import React from 'react';
import utilities from './tailwind.json';

const Section: React.FC<{
  title: string;
}> = ({children, title}) => {
  const isDarkMode = useColorScheme() === 'dark';
  return (
    <View style={styles.sectionContainer}>
      <Text
        style={[
          styles.sectionTitle,
          {
            color: isDarkMode ? Colors.white : Colors.black,
          },
        ]}>
        {title}
      </Text>
      <Text
        style={[
          styles.sectionDescription,
          {
            color: isDarkMode ? Colors.light : Colors.dark,
          },
        ]}>
        {children}
      </Text>
    </View>
  );
};

const CustomHeader = () => {
  const tailwind = useTailwind();
  return <Text style={tailwind('bg-primary')}>custom header3</Text>;
};

const App = () => {
  const isDarkMode = useColorScheme() === 'dark';

  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  };

  return (
    <TailwindProvider utilities={utilities}>
      <SafeAreaView style={backgroundStyle}>
        <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
        <ScrollView
          contentInsetAdjustmentBehavior="automatic"
          style={backgroundStyle}>
          <CustomHeader />
          <Header />
          <View
            style={{
              backgroundColor: isDarkMode ? Colors.black : Colors.white,
            }}>
            <Section title="Step One">
              Edit <Text style={styles.highlight}>App.tsx</Text> to change this
              screen and then come back to see your edits.
            </Section>
            <Section title="See Your Changes">
              <ReloadInstructions />
            </Section>
            <Section title="Debug">
              <DebugInstructions />
            </Section>
            <Section title="Learn More">
              Read the docs to discover what to do next:
            </Section>
            <LearnMoreLinks />
          </View>
        </ScrollView>
      </SafeAreaView>
    </TailwindProvider>
  );
};

const styles = StyleSheet.create({
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
  },
  highlight: {
    fontWeight: '700',
  },
});

export default App;

And all the configs are updated by npx setup-tailwind-rn.

I’m using the newest Xcode and simulator on M1 Max MBP

1reaction
grrbmcommented, Mar 28, 2022

neat ! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unsupported Tailwind class - tailwind.json is empty · Issue #156
I am using tailwind version 4.2.0, and after following the instruction for installation. My config file has been properly set-up My ...
Read more >
Why is my Tailwind ract native not changing anything?
It happens because tailwind-rn generates only the CSS it is really needed and everytime you add a tailwind class to an element, ...
Read more >
Configuration - Tailwind CSS
A guide to configuring and customizing your Tailwind installation. ... Now all of Tailwind's utility classes will be generated as !important :
Read more >
How to use Tailwind CSS in React Native | Lag and Log
Tailwind CSS is an open-source utility-first CSS framework. It redefines the way you style applications by providing a variety of CSS classes by...
Read more >
Tailwind CSS classes list
Tailwind CSS classes with source code and live preview. You can copy our examples and paste them into your project!
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