Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

NativeWind classes are ignored on React Navigation screens and components

ErrorclassName has no effect

Short answer

NativeWind only styles components it can reach. Check the Tailwind content paths, the babel preset, the Metro wrapper and the global.css import. Navigation options like headers and tab bars take style objects, not className, so use a theme or remapProps for third-party components.

  • Applies to NativeWind 4, Tailwind CSS 3.4, React Navigation 7, Expo SDK 53+
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out whether the failure is global or only inside navigation components. Put a plain View with a bright background class on any screen.

    <View className="flex-1 bg-red-500" />
  2. 2Match what you see, then jump to its fix

    1. 1No class works anywhere, not only in navigation.The NativeWind setup is incompleteFix
    2. 2Classes work in components but not on screens in another folder.The screen files are not in the Tailwind content listFix
    3. 3className works on View and Text but not on a library component.A third-party component does not forward classNameFix
    4. 4Class works inside screens, but header, tab bar and screen background do not follow it.Navigation chrome is styled through its theme, not classesFix

What does the error look like?

  • className has no effect
  • Tailwind classes do not apply to navigation screens

Cause 1 of 4

The NativeWind setup is incomplete

1Check

Four pieces are needed: content paths in tailwind.config.js, the nativewind preset, the babel entries and the Metro wrapper with the CSS input. global.css must be imported once in the root.

cat tailwind.config.js babel.config.js metro.config.js
grep -rn "global.css" App.tsx app/_layout.tsx

2Fix

Match the documented setup, and restart Metro afterwards.

// tailwind.config.js
content: ["./App.tsx", "./components/**/*.{js,jsx,ts,tsx}"],
presets: [require("nativewind/preset")],

// babel.config.js presets
["babel-preset-expo", { jsxImportSource: "nativewind" }],
"nativewind/babel",

// metro.config.js
module.exports = withNativeWind(config, { input: './global.css' })

3Verify

Restart Metro and the red View shows.

npx expo start --clear

Confirmed by nativewind.dev

Did this fix it?

Cause 2 of 4

The screen files are not in the Tailwind content list

1Check

The content list must name every file that uses NativeWind classes.

grep -n -A4 "content" tailwind.config.js

2Fix

Add every folder that contains className, such as screens, to content.

content: [
  "./App.tsx",
  "./components/**/*.{js,jsx,ts,tsx}",
  "./screens/**/*.{js,jsx,ts,tsx}",
],

3Verify

Restart Metro and the class appears on the screen.

npx expo start --clear

Confirmed by nativewind.dev

Did this fix it?

Cause 3 of 4

A third-party component does not forward className

1Check

If a component does not forward className to a style prop, the class is dropped silently.

grep -rn "className" src/ | head

2Fix

Map className to the component's style props once, at the app entry point.

remapProps(ThirdPartyComponent, {
  className: "style",
  contentContainerClassName: "contentContainerStyle",
});

3Verify

The class now changes the component.

# reload the app

Confirmed by nativewind.dev

Did this fix it?

Cause 4 of 4

Navigation chrome is styled through its theme, not classes

1Check

React Navigation reads colors for backgrounds, headers and tab bars from its theme object.

grep -rn "NavigationContainer\|theme=" src/ app/

2Fix

Pass a theme to the navigation container with your colors.

const MyTheme = {
  ...DefaultTheme,
  colors: { ...DefaultTheme.colors, background: 'rgb(255, 255, 255)' },
};
<NavigationContainer theme={MyTheme}>

3Verify

The screen background follows the theme color.

# reload and compare screens

Confirmed by reactnavigation.org

Did this fix it?

How do I stop it coming back?

  • Keep Tailwind content paths in sync when you add folders.
  • Restart Metro after changing tailwind, babel or metro config.
  • Use the theme for navigation chrome and className for your own components.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.