You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:基于NativeWind&Tailwind的Expo+React多主题Monorepo配置

Monorepo多主题配置方案求助(Yarn Workspaces + Expo托管工作流 + React+Vite)

我正在用Yarn Workspaces管理一个Monorepo项目,移动端采用Expo(托管工作流)、Web端采用React+Vite,两者均基于TypeScript模板。计划将主题配置统一放在共享文件夹中,但尚未找到可行方案,恳请提供解决方案或参考思路。

现有各平台Tailwind配置

移动端(Expo)tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  presets: [require('@expo-monorepo/shared/tailwind.config')],
  content: [
    './index.{js,jsx,ts,tsx}',
    './App.{js,jsx,ts,tsx}',
    './src/**/*.{js,jsx,ts,tsx}',
    '../Shared/**/*.{js,jsx,ts,tsx}',
  ],
  theme: {
    extend: {},
  },
  plugins: [require('nativewind/tailwind/native')],
};

共享文件夹tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [],
  theme: {
    extend: {
      colors: {
        'pastel-green': {
          50: '#f1fdf0',
          100: '#dbfddb',
          200: '#bbf8ba',
          300: '#85f184',
          400: '#63e663',
          500: '#1ec91f',
          600: '#13a613',
          700: '#138214',
          800: '#146716',
          900: '#135415',
          950: '#042f06',
        },
        candlelight: {
          50: '#feffe7',
          100: '#fcffc1',
          200: '#fdff86',
          300: '#fffa41',
          400: '#ffee0d',
          500: '#ffdf00',
          600: '#d1a500',
          700: '#a67602',
          800: '#895c0a',
          900: '#744b0f',
          950: '#442804',
        },
      },
    },
  },
  plugins: [],
};

Web端(React+Vite)tailwind.config.js

/** @type {import('tailwindcss').Config} */
export default {
  presets: [require('@expo-monorepo/shared/tailwind.config')],
  content: ['./src/**/*.{js,jsx,ts,tsx}'],
  theme: {
    extend: {},
  },
  plugins: [],
};

已尝试的方案及需求

我试过在共享文件夹中使用NativeWind的NativeWindStyleSheet API创建主题,也尝试过tailwindcss-themer插件和tailwindcss/plugin,但没掌握移动端的正确配置方式。最终期望实现的效果是:通过useColorScheme的colorScheme切换自定义主题(如christmas、halloween、my-theme等)。


内容的提问来源于stack exchange,提问作者Carlos Saraiva

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 03:34:54