MCPcopy Index your code
hub / github.com/EvanBacon/expo-apple-colors

github.com/EvanBacon/expo-apple-colors @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
14 symbols 33 edges 8 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@bacons/apple-colors

Use native adaptive iOS colors in your Expo app on all platforms.

This package provides typed bindings for all UIKit colors and native adaptive shims on Android and web. The web colors use CSS variables and support high gamut displays.

Add the package to your npm dependencies

This project requires a dev client on Android as the colors are added to the native resources via a config plugin.

yarn add @bacons/apple-colors

In your app.json:

{
  "expo": {
    "plugins": ["@bacons/apple-colors"]
  }
}

Usage

import * as Colors from "@bacons/apple-colors";

function App() {
  return (
    <>
      <View
        style={{
          backgroundColor: Colors.systemBackground,
        }}
      >
        {/* No TypeScript errors... */}
        <Text style={{ color: Colors.label }}>Link</Text>
      </View>
    </>
  );
}

You can lock the colors to a single scheme with Appearance.setColorScheme() from react-native.

Colors

Screenshot 2024-09-27 at 7 10 44 PM

Issue with Android

While this technically works and is setup correctly on Android, the PlatformColor API in React Native has a bug that makes it not update at runtime. This means the first time a component is mounted with the color, it will be the correct color, but if the appearance changes at runtime, it will not update. This is a limitation of React Native and not this package.

Core symbols most depended-on inside this repo

Shape

Function 14

Languages

TypeScript100%

Modules by API surface

scripts/generate.ts6 symbols
plugin/src/rgb-to-hex.ts4 symbols
plugin/src/withAndroidColors.ts2 symbols
src/colors.ts1 symbols
src/colors.android.ts1 symbols

For agents

$ claude mcp add expo-apple-colors \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page