Files
nativewind/website/docs/api/styled.md
2022-05-05 14:07:45 +10:00

729 B

sidebar_position, title, sidebar_label
sidebar_position title sidebar_label
2 styled styled()

styled is a Higher-Order Component which allows your component to accep the tw or className props. These props are compiled into StyleSheet objects and passed to your component via the style prop.

There is no difference between tw and className, but tw has priority.

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

const StyledText = styled(Text);

export function MyComponent() {
  return (
    <>
      <StyledText tw="font-bold">Hello world</StyledText>
      <StyledText className="font-bold">Hello world</StyledText>
    </>
  );
}