Skip to content

iChristosK/expo-apple-colors

 
 

Repository files navigation

@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>
    </>
  );
}

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.

About

Use native Apple colors on all platforms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 71.0%
  • CSS 19.7%
  • JavaScript 9.3%