Common Questions
How do I include custom fonts?
How do I include custom fonts?
Custom fonts require two steps: loading the font files into your app and configuring the font names in your CSS. Uniwind maps This will copy your font files to the native iOS and Android projects.
className props to font families, but the actual font files need to be included separately.Important: Uniwind only handles the mapping of classNames to font families. You must include and load the font files separately using Expo Font or React Nativeโs asset system.
Expo Projects
Step 1: Install and configure expo-font
Add the font files to your project and configure them inapp.json:app.json
Step 2: Define font families in global.css
Configure your font families and text sizes using CSS variables in the@theme directive:global.css
Step 3: Use font classes in your components
Now you can use the configured font families with Tailwind classes:Bare React Native Projects
For bare React Native projects without Expo, you can include fonts using thereact-native.config.js file:Step 1: Create react-native.config.js
react-native.config.js
Step 2: Link the fonts
Run the following command to link your fonts:Step 3: Configure in global.css
After linking the fonts, configure them in yourglobal.css the same way as Expo projects:global.css
Platform-Specific Fonts
You can define different fonts for different platforms using media queries:global.css
Troubleshooting
Fonts not loading
If your fonts arenโt appearing:- Check font file names - Make sure the font family name in CSS matches the font file name exactly
- Rebuild the app - Font changes require a full rebuild, not just a Metro refresh
- Verify file paths - Ensure the paths in
app.jsonorreact-native.config.jsare correct - Clear cache - Try clearing Metro bundler cache with
npx expo start --clear
Font looks different than expected
React Native doesnโt support dynamic font weights. Each weight requires its own font file. Make sure youโve:- Included all the font weight variants you need
- Mapped each variant to a CSS variable in
@theme - Used the correct className for each weight
Platform Selectors
Learn more about using platform-specific styles
How can I use gradients?
How can I use gradients?
Uniwind provides built-in gradient support using Tailwind syntax with React Nativeโs internal implementation. No additional dependencies required!Available directions:Syntax:
Built-in Gradient Support (Recommended)
Use gradient classes directly with theclassName prop:Directional Gradients
bg-gradient-to-t- Topbg-gradient-to-r- Rightbg-gradient-to-b- Bottombg-gradient-to-l- Leftbg-gradient-to-tr- Top rightbg-gradient-to-br- Bottom rightbg-gradient-to-bl- Bottom leftbg-gradient-to-tl- Top left
Angle-based Gradients
Use specific angles withbg-linear-{angle}:Multi-stop Gradients
Usefrom-, via-, and to- for multiple color stops:Custom Gradients with Arbitrary Values
For complete control, use arbitrary values with custom angles and color stops:bg-linear-[angle,color1_position,color2_position,...]Using expo-linear-gradient
If you need to useexpo-linear-gradient for specific features, you canโt use withUniwind since it doesnโt support mapping props to arrays. Instead, use multiple useCSSVariable calls:โ This wonโt work
โ Use useCSSVariable instead
Examples
Card with Gradient Background
Button with Gradient
Theme-aware Gradient
How do you handle merging and deduplicating classNames?
How do you handle merging and deduplicating classNames?
Uniwind does not automatically deduplicate classNames, especially on web. When you have conflicting styles or duplicate classes, youโll need to handle merging manually.
Important: Uniwind doesnโt dedupe classNames. If you pass conflicting styles like
className="bg-red-500 bg-blue-500", both classes will be applied, and the behavior depends on CSS specificity rules.Using tailwind-merge (Recommended)
For proper className merging and deduplication, we recommend usingtailwind-merge with a utility function:Step 1: Install dependencies
Step 2: Create a cn utility
Create a utility file (e.g.,lib/utils.ts or utils/cn.ts):lib/utils.ts
Step 3: Use the cn utility
Now you can merge classNames safely in your components:Why Use tailwind-merge?
Withouttailwind-merge, conflicting classes can cause issues:โ Without tailwind-merge
โ With tailwind-merge
Conditional Class Merging
Theclsx library inside cn makes conditional classes easier:How does style specificity work in Uniwind?
How does style specificity work in Uniwind?
Understanding style specificity and priority is important when working with Uniwind to ensure predictable styling behavior.Result: The background will be blue, not red.Result on all platforms: Purple background (inline style always wins)
Inline styles override className
In Uniwind inline styles always have higher priority than className:Platform-specific behavior
Specificity rules work consistently across platforms:Best practices
How can I fix Metro unstable_enablePackageExports conflicts?
How can I fix Metro unstable_enablePackageExports conflicts?
Some React Native apps (especially crypto apps) need to disable Uniwind and its dependency (
unstable_enablePackageExports in their Metro configuration. However, Uniwind requires this setting to be enabled to work properly.The Problem
If your Metro config has:metro.config.js
culori) wonโt work correctly because they require package exports to be enabled.The Solution
You can selectively enable package exports only for Uniwind and its dependencies while keeping it disabled for everything else:metro.config.js
Why This Works
The customresolveRequest function:- Checks the module name - If itโs
uniwindorculori, it enables package exports - Creates a new context - Temporarily overrides the setting for these specific packages
- Falls back to default - All other packages use the global setting (
false)
When You Need This
Use this solution if:- Youโre working with crypto libraries that break with package exports enabled
- You have other dependencies that require
unstable_enablePackageExports = false - You encounter module resolution errors with Uniwind after disabling package exports
If you donโt have any conflicts with
unstable_enablePackageExports, you donโt need this custom resolver. Uniwind works fine with the default Metro configuration.Troubleshooting
If you still encounter issues after adding the custom resolver:- Clear Metro cache - Run
npx expo start --clearornpx react-native start --reset-cache - Rebuild the app - Package export changes may require a full rebuild
- Check the module name - Ensure the module causing issues is included in the
['uniwind', 'culori']array - Verify Metro config - Make sure the custom resolver is defined before calling
withUniwindConfig
Metro Configuration
Learn more about configuring Metro for Uniwind