Files
nativewind/website/docs/compilation/postcss-css.md
2022-05-05 14:07:45 +10:00

1.1 KiB

sidebar_position, sidebar_label
sidebar_position sidebar_label
4 PostCSS (CSS) 🔬

import ReactNativeWebPreview from "./_react-native-web-0-18-preview.md"

Using PostCSS (CSS) 🔬

1. Setup Tailwind CSS

Follow the Using PostCSS to setup Tailwind CSS

2. Setup tailwindcss-react-native

Follow the general setup instructions to setup tailwindcss-react-native.

3. Enable preview features

You will need to enable preview features on your TailwindProvider

import { TailwindProvider } from 'tailwindcss-react-native'

function MyAppsProviders ({ children }) {
  return (
-   <TailwindProvider>{children}</TailwindProvider>
+   <TailwindProvider preview={true}>{children}</TailwindProvider>
  )
}

4. Write components using the Component API

import { Text } from "react-native";
import { styled } from "tailwindcss-react-native";

const StyledText = styled(Text);

export function BoldText(props) {
  return <StyledText className="font-bold" {...props} />;
}