@molecule/app-ui-nativewind

Provider bond · ui · App (browser) · v1.7.0 · Apache-2.0

NativeWind UIClassMap bond for React Native

npm install @molecule/app-ui-nativewind

npm · Source on GitHub · Implements @molecule/app-ui

How it works

@molecule/app-ui-nativewind is a provider bond on the app (browser) side: it implements the ui core interface (@molecule/app-ui) with a concrete vendor or library behind it.

Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.

import { setClassMap } from '@molecule/app-ui'
import { classMap } from '@molecule/app-ui-nativewind'

setClassMap(classMap) // once, at app startup

Works with: @molecule/app-ui-tailwind

Reference

NativeWind UIClassMap bond for React Native, and the Tailwind preset that gives its classes the web's values on iOS, Android and Expo web.

The ClassMap is the web ClassMap (@molecule/app-ui-tailwind) with every class a device cannot apply rewritten: sibling spacing (space-y-*) becomes gap-y-*; group/peer, pseudo-element, arbitrary-selector and divider classes are dropped; a border with no colour gets the text colour the web draws it in. The preset (@molecule/app-ui-nativewind/preset) defines what the ClassMap names: every theme colour as a CSS variable the theme bond (@molecule/app-theme-nativewind) sets, the font roles, the animations and Tailwind 4's radius, shadow and blur scales.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { setClassMap } from '@molecule/app-ui'
import { classMap } from '@molecule/app-ui-nativewind'

setClassMap(classMap) // once, at app startup
// tailwind.config.js
const molecule = require('@molecule/app-ui-nativewind/preset')

module.exports = {
  content: ['./src/**/*.{ts,tsx}', ...molecule.moleculeContent(__dirname)],
  presets: [require('nativewind/preset'), molecule],
}

Type

provider

Installation

npm install @molecule/app-ui-nativewind @molecule/app-ui-tailwind react
npm install -D @types/react

API

Constants

classMap

NativeWind UIClassMap — Tailwind classmap with RN-compatible overrides.

Wire at app startup:

import { setClassMap } from '@molecule/app-ui'
import { classMap } from '@molecule/app-ui-nativewind'
setClassMap(classMap)
const classMap: UIClassMap

Core Interface

Implements @molecule/app-ui interface.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-styling ^1.0.1 (optional)
  • @molecule/app-ui ^1.7.0 (optional)
  • @molecule/app-ui-tailwind ^1.0.1
  • nativewind ^4.2.0 (optional)
  • react ^18.0.0 || ^19.0.0
  • react-native-svg ^15.11.2 (optional)
  • tailwindcss ^3.4.0 (optional)

Runtime Dependencies

  • @molecule/app-styling (optional)

  • @molecule/app-ui (optional)

  • @molecule/app-ui-tailwind

  • nativewind (optional)

  • react

  • react-native-svg (optional)

  • tailwindcss (optional)

  • Without the preset in tailwind.config.js, no theme colour class (bg-surface, text-foreground, …) generates a style: the screen renders with no colours.

  • moleculeContent(__dirname) returns the ClassMap packages' dist folders wherever npm installed them. Literal ./node_modules/@molecule/... globs match nothing once npm hoists the packages (any workspace).

  • Pass inlineRem: 16 to withNativeWind in metro.config.js so rem sizes match the web (NativeWind's default is 14).

  • This package emits class strings: the app configures NativeWind v4 itself (Babel preset, metro.config.js, tailwind.config.js). nativewind is not a dependency of this package.

  • No CSS grid (grid() approximates it with flex-wrap), no hover: (touch uses active:), no backdrop-blur, no position: fixed, no portals (RN Modal handles overlays), no prose. Animations run on Reanimated. Don't hand-write utilities in app code: go through getClassMap().