@factorialco/f0-react-native

中文文档
1.1.0发布于 2026/11/12MITTypeScriptESM + CJS近 30 天下载 6770

React Native components for F0 Design System

原始使用文档
文档目录27 节
  1. New Architecture compatibility
  2. Supported compatibility matrix
  3. 🚀 Quick Setup
  4. 1️⃣ Install Dependencies
  5. 2️⃣ Configure Babel
  6. 3️⃣ Configure Metro
  7. 4️⃣ Create Global CSS
  8. 5️⃣ Add Inter Fonts (Host App)
  9. 6️⃣ TypeScript Support (Optional)
  10. 🤖 PR Previews (Published with React Native ALPHA)
  11. Required Secret
  12. How it appears in GitHub
  13. 📱 Expo Go (Latest Update)
  14. ✅ Latest Update
  15. 🔗 Deep Link
  16. 📲 QR Code
  17. 📦 Usage
  18. Basic Component Usage
  19. Using the cn Utility
  20. Component Variants
  21. 🔧 Troubleshooting
  22. Classes Not Being Detected by Uniwind
  23. TypeScript Errors with Variants
  24. Build Errors
  25. 🔧 Development
  26. 📦 Peer Dependencies
  27. 📄 License

F0 React Native 🎨

🚧 Status: WIP — We are building this design system from the ground up. Expect changes and breaking changes as we iterate. 🏗️

React Native implementation of the F0 Design System.

New Architecture compatibility

This package supports React Native New Architecture only (Fabric/TurboModules) and Expo SDK 54+ only. See docs/new-architecture.md for requirements and troubleshooting (notably Reanimated + Uniwind host app setup).

Supported compatibility matrix

Host stackSupport
Expo SDK 54+✅ Supported
Expo SDK 53 and below❌ Not supported
New Architecture enabled (expo.newArchEnabled)✅ Required
Old Architecture❌ Not supported

🚀 Quick Setup

1️⃣ Install Dependencies

# 1) Install package + JS peer dependencies
pnpm add @factorialco/f0-react-native \
  date-fns@^3.6.0 \
  tailwind-merge@^3.4.0 \
  tailwind-variants@^3.2.2 \
  tailwindcss@^4.1.18 \
  uniwind@^1.2.7 \
  twemoji-parser@^14.0.0

# 2) Install Expo-native dependencies pinned to your SDK
npx expo install \
  expo-image \
  react-native-reanimated \
  react-native-worklets \
  react-native-safe-area-context \
  react-native-svg

Note: The following peer dependencies are required:

  • uniwind and tailwindcss - Required for styling (must be configured in Metro and CSS files)
  • tailwind-merge and tailwind-variants - Required for component variant system and class merging
  • react-native-reanimated - Required for animations
  • react-native-worklets - Required by Reanimated 4
  • react-native-safe-area-context - Required for safe area handling
  • react-native-svg - Required for icon components
  • date-fns - Required for date utilities
  • twemoji-parser - Required for emoji support

2️⃣ Configure Babel

babel.config.js:

module.exports = function (api) {
  api.cache(true)
  return {
    presets: ["babel-preset-expo"], // Expo only
  }
}

Note: In managed Expo SDK 54+ apps using the standard babel-preset-expo, Reanimated/Worklets Babel plugins are already included and should not be added manually. In custom/bare hosts, follow docs/new-architecture.md and add the required plugins explicitly.

3️⃣ Configure Metro

metro.config.js:

const { getDefaultConfig } = require("expo/metro-config")
const { withUniwindConfig } = require("uniwind/metro")

const config = getDefaultConfig(__dirname)

// Ensure CSS files trigger reloads
config.resolver.sourceExts = [...(config.resolver.sourceExts || []), "css"]

module.exports = withUniwindConfig(config, {
  cssEntryFile: "./global.css",
  dtsFile: "./uniwind-types.d.ts",
})

4️⃣ Create Global CSS

global.css (root):

@import "tailwindcss";
@import "uniwind";

/* Import F0 styles (theme tokens + base styles) */
@import "@factorialco/f0-react-native/styles";

/* Add your app's source paths for Tailwind CSS v4 */
@source "./app/**/*.{js,jsx,ts,tsx}";
@source "./src/**/*.{js,jsx,ts,tsx}";

/* Add F0 component sources so Tailwind can detect classes */
@source "./node_modules/@factorialco/f0-react-native/lib";

/* Also scan library source files */
@source "./node_modules/@factorialco/f0-react-native/src/**/*.{js,jsx,ts,tsx}";

Import in your entry file (App.tsx or index.js):

import "./global.css"

Note: Add @source "./node_modules/@factorialco/f0-react-native/lib"; so Tailwind can detect all component classes.

5️⃣ Add Inter Fonts (Host App)

F0 components use the Inter font family. The host app must embed the font files and register them with Uniwind so both iOS and Android resolve them correctly.

Step A: Add font files

Place the Inter .ttf files in your project. File names must match the PostScript name embedded in each font file (you can inspect PostScript names with tools like fc-query or fontTools):

assets/fonts/Inter/
  Inter-Regular.ttf      # PostScript name: Inter-Regular   (weight 400)
  Inter-Medium.ttf       # PostScript name: Inter-Medium    (weight 500)
  Inter-SemiBold.ttf     # PostScript name: Inter-SemiBold  (weight 600)
  Inter-Bold.ttf         # PostScript name: Inter-Bold      (weight 700)

Why file names matter: iOS resolves fonts by PostScript name, Android by asset file name (minus extension). When they match, a single CSS value works on both platforms without platform-specific overrides.

Step B: Register with expo-font

Add the expo-font config plugin to your app.json:

[
  "expo-font",
  {
    "fonts": [
      "./assets/fonts/Inter/Inter-Regular.ttf",
      "./assets/fonts/Inter/Inter-Medium.ttf",
      "./assets/fonts/Inter/Inter-SemiBold.ttf",
      "./assets/fonts/Inter/Inter-Bold.ttf"
    ]
  }
]

This embeds the fonts at build time — no runtime useFonts call needed.

Step C: Define font variables in global.css

Add a @theme block after the F0 style imports:

@theme {
  --font-normal: "Inter-Regular";
  --font-medium: "Inter-Medium";
  --font-semibold: "Inter-SemiBold";
  --font-bold: "Inter-Bold";
}

The values must match the file names (without .ttf). Uniwind maps Tailwind font-normal, font-medium, font-semibold, and font-bold utilities to these variables.

Rebuild required: Font changes are picked up at build time, not via Metro hot reload. Run npx expo prebuild --clean && npx expo run:ios (or run:android) after adding or renaming font files.

6️⃣ TypeScript Support (Optional)

uniwind-types.d.ts (root):

/// <reference types="uniwind/types" />

This file is automatically generated by Uniwind when you run Metro. You can add it to your .gitignore if desired.

🤖 PR Previews (Published with React Native ALPHA)

Expo preview publishing is tied to the React Native ALPHA workflow. The QR comment is posted only when the React Native ALPHA publish job succeeds.

  • Trigger source: React Native ALPHA workflow (build-and-publish-alpha)
  • Scope: runs when the React Native package changes (or when manually triggered with the build PR comment path in that workflow)
  • Publish branch: development
  • Update message: latest commit message (via eas update --auto)
  • PR output: one updatable comment with Expo Go links and a QR code

Required Secret

Add this repository secret in GitHub:

  • EXPO_TOKEN: personal access token from Expo account settings

How it appears in GitHub

On each PR update, CI posts or updates a single comment containing:

  • Update metadata (message, group ID, timestamp)
  • Expo update page link
  • Direct QR link
  • Embedded QR image for quick scan in Expo Go

📱 Expo Go (Latest Update)

Use this section after each manual update so people can install the latest build in Expo Go.

✅ Latest Update

  • Branch / Channel: production
  • Update message: F0Text and AnimatedF0Text
  • Published at: Mar 4, 2026

📲 QR Code

Expo Go QR Code

Android note: If scanning the QR code with your device camera opens a browser or shows a 404, open Expo Go and use its built-in QR scanner.

📦 Usage

Basic Component Usage

import { F0Button, F0Icon, AppIcons } from "@factorialco/f0-react-native"

export default function App() {
  return (
    <>
      <F0Button label="Click me" variant="default" size="md" />
      <F0Icon icon={AppIcons.Calendar} size="md" />
    </>
  )
}

Legacy Button and Icon remain available for backward compatibility, but are deprecated.

Using the cn Utility

The package exports a cn utility function for merging Tailwind classes with automatic conflict resolution:

import { cn } from "@factorialco/f0-react-native"
import { View } from "react-native"

function MyComponent({ className, isActive }) {
  return (
    <View
      className={cn(
        "rounded-lg bg-background p-4",
        "border-divider border",
        isActive && "bg-accent",
        className
      )}
    />
  )
}

The cn utility:

  • ✅ Automatically merges Tailwind classes with conflict resolution
  • ✅ Uses tailwind-merge under the hood
  • ✅ Supports custom opacity class groups
  • ✅ Properly handles conditional classes

Component Variants

All components use tailwind-variants for type-safe variant props:

import { F0Button } from "@factorialco/f0-react-native"

// Type-safe variants
;<F0Button
  label="Primary Button"
  variant="default" // ✅ Autocomplete: "default" | "outline" | "critical" | "neutral" | "ghost" | "promote"
  size="md" // ✅ Autocomplete: "sm" | "md" | "lg"
/>

🔧 Troubleshooting

Classes Not Being Detected by Uniwind

If styles from F0 components aren't being applied, ensure:

  1. Import styles and add source paths: Your global.css includes the F0 styles and the F0 source path:

    @import "@factorialco/f0-react-native/styles";
    @source "./node_modules/@factorialco/f0-react-native/lib";
    
  2. Metro Cache: Clear Metro bundler cache:

    npx expo start --clear
    # or
    npm start -- --reset-cache
    
  3. Dependencies: Verify all peer dependencies are installed:

    pnpm list tailwind-merge tailwind-variants tailwindcss uniwind
    

TypeScript Errors with Variants

If you see TypeScript errors related to variants, ensure tailwind-variants is installed:

pnpm add tailwind-variants@^3.2.2

Build Errors

If you encounter build errors, ensure:

  • All peer dependencies are installed
  • Metro config includes CSS file extensions
  • Babel plugins are properly configured

🔧 Development

# Run tests
pnpm test

# Type check
pnpm tsc

# Lint
pnpm lint

# Build package
pnpm build

📦 Peer Dependencies

This package requires the following peer dependencies to be installed in your host project:

PackageVersionRequiredPurpose
react*✅ YesReact library
react-native*✅ YesReact Native framework
tailwindcss^4.1.18✅ YesCSS framework
uniwind^1.2.7✅ YesTailwind CSS for React Native
tailwind-merge^3.4.0✅ YesClass merging utility
tailwind-variants^3.2.2✅ YesVariant system
react-native-reanimated>=4.1.1 <5.0.0✅ YesAnimations
react-native-worklets>=0.5.1 <1.0.0✅ YesWorklet runtime for Reanimated 4
react-native-safe-area-context^5.6.0✅ YesSafe area handling
react-native-svg^15.12.1✅ YesSVG support for icons
expo-image~3.0.11✅ YesImage rendering
expo-blur~15.0.8✅ YesBlur effects
date-fns^3.6.0✅ YesDate utilities
twemoji-parser^14.0.0✅ YesEmoji support

📄 License

MIT

版本与发布记录

@factorialco/f0-react-native 共发布 55 个版本,首次发布于 2025/09/11;过去 12 个月发布了 52 个版本。

版本发布日期距今
1.1.0latest2026/11/121 天前
1.0.02026/10/2123 天前
0.62.02026/10/1926 天前
0.61.02026/10/011 个月前
0.60.02026/09/181 个月前
0.59.12026/08/272 个月前

关于 @factorialco/f0-react-native 的常见问题

@factorialco/f0-react-native 是什么?

React Native components for F0 Design System

如何安装 @factorialco/f0-react-native?

在项目目录运行 npm install @factorialco/f0-react-native,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、uniwind(^1.9.0)、date-fns(^3.6.0)、expo-blur(*)、expo-image(*)、tailwindcss(^4.1.18)、react-native(*)、expo-clipboard(*)、tailwind-merge(^3.4.0)、twemoji-parser(^14.0.0)、react-native-svg(^15.12.1)、tailwind-variants(^3.2.2)、react-native-worklets(>=0.5.1 <1.0.0)、react-native-reanimated(>=4.1.1 <5.0.0)、react-native-safe-area-context(^5.6.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@factorialco/f0-react-native 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@factorialco/f0-react-native 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@factorialco/f0-react-native 可以商用吗?

@factorialco/f0-react-native 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@factorialco/f0-react-native 的下载量有多少?

根据 npm 官方下载统计,@factorialco/f0-react-native 在 2026/10/14 – 2026/11/12 这 30 天内被下载 6,770 次,日均约 226 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@factorialco/f0-react-native 还在维护吗?

最新版本 1.1.0 发布于 2026/11/12(1 天前);至今共发布 55 个版本,其中过去 12 个月发布了 52 个;首次发布于 2025/09/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。