Re-skin a whole React Native app with two commands
Most theming systems in React Native mix two different things together:
- Color: background, foreground, primary, borders, in light and dark.
- Shape and feel: corner radius, type scale, spacing, whether cards have shadows or borders, whether inputs are filled or outlined.
When they're mixed, "make it look more like iOS" turns into a hunt through dozens of tokens. In Nativra I split them into two independent settings, theme and style, and either one can change at any time.
Themes: the colors
There are 10 built-in themes, each with light and dark: zinc, slate, dark-slate, midnight, violet, rose, orange, amber, emerald and cyan.
npx nativra-cli theme add midnight --overwrite Styles: everything that isn't color
There are 5 styles:
| Style | Looks like |
|---|---|
soft | Pill buttons, rounded cards, soft shadows (the default) |
crisp | shadcn/ui: small radii, thin borders, compact |
tailwind | Tailwind UI: subtle rings, layered shadows, roomy spacing |
material | Material 3: tinted surfaces, filled inputs |
ios | iOS: grey grouped surfaces, larger type |
npx nativra-cli style add material Why this works without touching components
When you add a component, the CLI also adds a few shared files:
hooks/use-theme-colors.ts reads your theme and style lib/themes/theme.ts your color theme lib/themes/style.ts your style: shape, type, spacing Components read colors and style values through that hook. They never hard-code a color or a size. So when theme.ts or style.ts changes, every installed component picks it up, and you don't edit any component code.
In NativeWind projects, the CLI also updates the theme block in global.css, so your Tailwind classes match.
A practical workflow
What I do when starting an app:
-
npx nativra-cli init, then pick a style that's close to the product's feel. - Add the components for the first screens.
- Try a couple of themes on a real device before committing to one.
- Once the designer has real brand colors, edit
lib/themes/theme.tsdirectly. It's just your file.
Step 4 is the point of the copy-into-your-project model: the built-in themes are a starting point, not a cage.
Mix and match
Because theme and style are independent, the combinations multiply: ios style with emerald colors, crisp with midnight, and so on. That's 50 combinations before you customize anything, and you can preview them in the playground without installing.
How do you structure theming in your RN apps today: one big token object, or separate layers like this?
Nativra: UI components for React Native and Expo that you copy into your project and own. Every component ships in NativeWind and plain StyleSheet versions.
Docs · Playground · GitHub · npm
原文:https://www.a8q9.cn/en/article/re-skin-a-whole-react-native-app-with-two-commands-33b99b.html