You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: skills/migrate-nativewind-to-uniwind/SKILL.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -414,6 +414,15 @@ import { cn } from '@/lib/cn';
414
414
415
415
Use `cn` instead of raw `twMerge` — it handles conditional classes, arrays, and falsy values via `clsx` before deduplicating with `tailwind-merge`.
416
416
417
+
Important utilities are also supported in Uniwind. If migrated NativeWind code intentionally forces an override with Tailwind's important modifier, keep it:
Important utilities override non-important utilities for the same style property. Inline `style` still has the highest priority, even over important className utilities.
425
+
417
426
## Step 14: Update Animated Class Names
418
427
419
428
If the project used NativeWind `animated-*` / transition class patterns, migrate those to explicit `react-native-reanimated` usage. Uniwind OSS does not provide NativeWind-style animated class behavior.
(sm:/md:/lg:), important utilities (!bg-red-500), tailwind-variants, tv() variants, ScopedTheme, Uniwind.setTheme,
11
11
Uniwind.updateCSSVariables, @theme, @utility, @variant, CSS variables in RN,
12
12
colorClassName, tintColorClassName, contentContainerClassName, Uniwind Pro
13
13
(animations, transitions, shadow tree, native insets), safe area utilities,
@@ -39,6 +39,7 @@ Uniwind brings Tailwind CSS v4 to React Native. All core React Native components
39
39
11.**rem default is 16px** — NativeWind used 14px. Set `polyfills: { rem: 14 }` in metro config if migrating.
40
40
12.**`cssEntryFile` must be a relative path string** — Use `'./global.css'` not `path.resolve(__dirname, 'global.css')`.
41
41
13.**Deduplicate with `cn()` when mixing custom CSS classes and Tailwind** — Uniwind does NOT auto-deduplicate. If a custom CSS class (`.card { padding: 16px }`) and a Tailwind utility (`p-6`) set the same property, both apply with unpredictable results. Always wrap with `cn('card', 'p-6')` when there's overlap.
42
+
14.**Important utilities are supported** — Tailwind important modifier works in classNames: `!bg-red-500`, `active:!bg-red-500`, `ios:!pt-12`. Important utilities override non-important utilities for the same style property, but inline `style` still overrides className.
42
43
43
44
## Setup
44
45
@@ -741,6 +742,27 @@ import { cn } from '@/lib/cn';
741
742
- Static className with no conflicts: `<View className="flex-1 p-4 bg-white" />`
742
743
- Single custom CSS class with no overlapping Tailwind: `<View className="card-shadow mt-4" />` (if card-shadow only sets box-shadow which no Tailwind class also sets)
743
744
745
+
## Important Utilities and Style Specificity
746
+
747
+
Uniwind supports Tailwind's important modifier (`!`) for utilities that must override another utility for the same style property.
748
+
749
+
```tsx
750
+
import { View, Pressable } from'react-native';
751
+
752
+
// !bg-red-500 has higher priority than bg-blue-500
753
+
<ViewclassName="bg-blue-500 !bg-red-500" />;
754
+
755
+
// Important utilities work with state and platform variants
- Important utility (`!bg-red-500`) overrides non-important utility (`bg-blue-500`) for the same property.
762
+
- Important variants work normally: `active:!bg-red-500`, `ios:!pt-12`, `dark:!text-white`.
763
+
- Inline `style` always wins, even over important className utilities: `<View className="!bg-red-500" style={{ backgroundColor: 'blue' }} />` renders blue.
764
+
- Use `!` sparingly. For reusable components and consumer overrides, prefer `cn()` with `tailwind-merge`.
765
+
744
766
## Theming
745
767
746
768
### Quick Setup (dark: prefix)
@@ -2057,7 +2079,7 @@ Yes, since v1.2.0. Use `uniwind/vite` plugin alongside `@tailwindcss/vite`.
2057
2079
Metro can't hot-reload files with many providers. Move `global.css` import deeper in the component tree.
2058
2080
2059
2081
**Style specificity?**
2060
-
Inline `style` always overrides `className`. Use `className` for static styles, inline only for truly dynamic values. Use `cn()` from tailwind-merge for component libraries where classNames may conflict.
2082
+
Important utilities like `!bg-red-500` override non-important utilities for the same property and work with variants (`active:!bg-red-500`, `ios:!pt-12`). Inline `style` always overrides `className`, even important utilities. Use `className` for static styles, inline only for truly dynamic values. Use `cn()` from tailwind-merge for component libraries where classNames may conflict.
2061
2083
2062
2084
**How do I include custom fonts?**
2063
2085
Load font files (Expo: `expo-font` plugin in `app.json`; Bare RN: `react-native-asset`), then map in CSS: `@theme { --font-sans: 'Roboto-Regular'; }`. Font name must exactly match the file name. See the **Fonts** section above.
0 commit comments