Skip to content

Commit f1bd00a

Browse files
authored
docs: update skill with important properties (#536)
1 parent 5f4d7f1 commit f1bd00a

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

skills/migrate-nativewind-to-uniwind/SKILL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,15 @@ import { cn } from '@/lib/cn';
414414

415415
Use `cn` instead of raw `twMerge` — it handles conditional classes, arrays, and falsy values via `clsx` before deduplicating with `tailwind-merge`.
416416

417+
Important utilities are also supported in Uniwind. If migrated NativeWind code intentionally forces an override with Tailwind's important modifier, keep it:
418+
419+
```tsx
420+
<View className="bg-blue-500 !bg-red-500" />
421+
<Pressable className="bg-blue-500 active:!bg-red-500" />
422+
```
423+
424+
Important utilities override non-important utilities for the same style property. Inline `style` still has the highest priority, even over important className utilities.
425+
417426
## Step 14: Update Animated Class Names
418427

419428
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.

skills/uniwind/SKILL.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: >
77
@import 'uniwind', withUniwindConfig, withUniwind, metro.config.js with Uniwind,
88
useResolveClassNames, useCSSVariable, getCSSVariable, useUniwind, dark:/light: theming, platform
99
selectors (ios:/android:/native:/web:/tv:), data-[prop=value], responsive breakpoints
10-
(sm:/md:/lg:), tailwind-variants, tv() variants, ScopedTheme, Uniwind.setTheme,
10+
(sm:/md:/lg:), important utilities (!bg-red-500), tailwind-variants, tv() variants, ScopedTheme, Uniwind.setTheme,
1111
Uniwind.updateCSSVariables, @theme, @utility, @variant, CSS variables in RN,
1212
colorClassName, tintColorClassName, contentContainerClassName, Uniwind Pro
1313
(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
3939
11. **rem default is 16px** — NativeWind used 14px. Set `polyfills: { rem: 14 }` in metro config if migrating.
4040
12. **`cssEntryFile` must be a relative path string** — Use `'./global.css'` not `path.resolve(__dirname, 'global.css')`.
4141
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.
4243

4344
## Setup
4445

@@ -741,6 +742,27 @@ import { cn } from '@/lib/cn';
741742
- Static className with no conflicts: `<View className="flex-1 p-4 bg-white" />`
742743
- 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)
743744

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+
<View className="bg-blue-500 !bg-red-500" />;
754+
755+
// Important utilities work with state and platform variants
756+
<Pressable className="bg-blue-500 active:!bg-red-500" />;
757+
<View className="pt-4 ios:!pt-12 android:!pt-8" />;
758+
```
759+
760+
Priority rules:
761+
- 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+
744766
## Theming
745767

746768
### Quick Setup (dark: prefix)
@@ -2057,7 +2079,7 @@ Yes, since v1.2.0. Use `uniwind/vite` plugin alongside `@tailwindcss/vite`.
20572079
Metro can't hot-reload files with many providers. Move `global.css` import deeper in the component tree.
20582080

20592081
**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.
20612083

20622084
**How do I include custom fonts?**
20632085
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

Comments
 (0)