UNPKG

react-native-font-color-hook

Version:

React Native hook that applies dark font color for light mode and light font color for dark mode.

22 lines (19 loc) 567 B
import { useMemo } from 'react'; import { StyleSheet } from 'react-native'; import { useColorScheme } from 'react-native-appearance'; const useFontColor = (lightModeColor, darkModeColor) => { const styles = useMemo( () => StyleSheet.create({ white: { color: darkModeColor || 'white', }, black: { color: lightModeColor || 'black', }, }), [lightModeColor, darkModeColor], ); const colorScheme = useColorScheme(); return colorScheme === 'light' ? styles.black : styles.white; }; export default useFontColor;