input.css - Entrypoint for Tailwind compiler. It's required to override the output of Tailwind, so that it doesn't generate CSS for resetting browser styles, which will cause tailwind-rn to fail.
Disable unsupported utilities by adding this line to your tailwind.config.js:
$ tailwind-rn --help Use Tailwind CSS in React Native projects Usage $ tailwind-rn [options] Options -i, --input Path to CSS file that Tailwind generates (default: tailwind.css) -o, --output Output file (default: tailwind.json) -w, --watch Watch for changes and rebuild as needed
Run tailwind-rn CLI to transform the CSS generated by Tailwind into a JSON file that can be consumed by TailwindProvider. Add --watch flag to watch for changes and build styles continuously, which is useful for development.
API
TailwindProvider
utilities
Type: object
Parsed JSON object of styles generated by tailwind-rn CLI stored in tailwind.json by default.
import {TailwindProvider} from 'tailwind-rn';import utilities from './tailwind.json';const App = () => ( <TailwindProvider utilities={utilities}> <MyComponent /> </TailwindProvider>);
colorScheme
Type: string
Override the default color scheme. Possible values are light or dark.
import {TailwindProvider} from 'tailwind-rn';import utilities from './tailwind.json';const App = () => ( <TailwindProvider utilities={utilities} colorScheme="dark"> <MyComponent /> </TailwindProvider>);
useTailwind
React hook, which returns a tailwind function, that accepts a string with class names. This function returns an object of styles, which can be applied to a React Native view via style property.
Note: Add TailwindProvider above the component where you're using this hook.