Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

@media (prefers-color-scheme: dark) not working with Expo 54

未关闭
#255 1 条评论 3 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 3 天内回复

@danstepanov 已经在做这个了。

开始于 2025年10月24日。

评估

这个 Issue 还没有评估数据。

描述

deferred (post-5.0) help wanted

Describe the bug
@media (prefers-color-scheme: dark) does not work with ios. It does however work on web. It is clear the problem is with the media query because React's useColorScheme hook is working fine.

Reproduction
Here is trimmed version of my globals.css file:

@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);
@import "tailwindcss/utilities.css";

@import "nativewind/theme";

@theme {
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-destructive: var(--destructive);
}

:root {
  --radius: 0.625rem;
  --background: #ffffff;
  --foreground: #252525;
  --card: #ffffff;
  --card-foreground: #252525;
  --popover: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #252525;
    --foreground: #fbfbfb;
    --card: #343434;
    --card-foreground: #fbfbfb;
    --popover: #444444;
  }
}

Here is my expo config:

{
  "expo": {
    "name": "expo-starter",
    "slug": "expo-starter",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "expostarter",
    "userInterfaceStyle": "automatic",
    "newArchEnabled": true,
    "androidStatusBar": {
      "backgroundColor": "#000000",
      "barStyle": "light-content",
      "translucent": false
    },
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.ekrich.expostarter",
      "infoPlist": {
        "ITSAppUsesNonExemptEncryption": false
      }
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "edgeToEdgeEnabled": true,
      "package": "com.ekrich.expostarter"
    },
    "web": {
      "bundler": "metro",
      "output": "server",
      "favicon": "./assets/images/favicon.png"
    },
    "plugins": [
      "expo-router",
      [
        "expo-splash-screen",
        {
          "image": "./assets/images/splash-icon.png",
          "imageWidth": 200,
          "resizeMode": "contain",
          "backgroundColor": "#ffffff"
        }
      ],
      "expo-font",
      "expo-web-browser"
    ],
    "experiments": {
      "typedRoutes": true
    },
    "extra": {
      "router": {},
      "eas": {
        "projectId":  "my id"
      }
    },
    "runtimeVersion": {
      "policy": "appVersion"
    },
  }
}

I am running expo go for demo purposes (this is for a ui library).

Full reproduction link

Expected behavior
The theme colors should correctly switch with dark/light mode on native platforms as well.

Additional context
Discord thread discussing the issue.

主要语言
TypeScript
星标
166
派生
45
平均合并
13 天 14 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nativewind/react-native-css 的其他 Issue

查看 nativewind/react-native-css 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。