0.3.5 • Published 6 months ago

react-native-css-modules v0.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

react-native-css-modules · GitHub license npm version

Use CSS modules in React Native & React Native Web

npm i react-native-css-modules

Note: this package is in early development, use with caution

Must be used with Metro web

Features

  • Minimal selector support (.button.small)
  • CSS Vars

Setup

For app developers

Metro config for React Native

SWC plugin for Next.js

For library developers

Babel plugin

Usage

.Button {
  background-color: white;
  padding: 10px;
  border-radius: 5px;

  &.disabled {
    background-color: grey;
  }

  &.small {
    padding: 5px;
  }
}
import {View} from "react-native";

import styles from "./Button.module.scss";

import {useDynamicStyles} from "react-native-css-modules";

const Button = ({children, disabled, small}) => {
  const dynamicStyles = useDynamicStyles();

  return <View style={dynamicStyles([
    styles.Button,
    disabled && styles.disabled,
    small && styles.small
  ])}>
    {children}
  </View>;
};

export default Button;
<Button></Button>

All style props must be wrapped in a dynamicStyles() call from the useDynamicStyles hook to support selectors & CSS vars. If you want to automatically create wrapped versions of the primitive components from RN, use dynamicallyStyled():

0.3.5

6 months ago

0.3.2

6 months ago

0.3.1

6 months ago

0.3.4

6 months ago

0.3.3

6 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.3.0-alpha.2

10 months ago

0.3.0-alpha.3

10 months ago

0.3.0-alpha.4

10 months ago

0.3.0-alpha.1

10 months ago

0.1.0

12 months ago

0.0.1

1 year ago

0.0.3

1 year ago

0.1.1

12 months ago

0.0.2

1 year ago

0.1.4

12 months ago

0.1.3

12 months ago

0.0.4

1 year ago

0.0.1-alpha.15

1 year ago

0.0.1-alpha.14

1 year ago

0.0.1-alpha.13

1 year ago

0.0.1-alpha.12

1 year ago

0.0.1-alpha.11

1 year ago

0.0.1-alpha.10

1 year ago

0.0.1-alpha.9

1 year ago

0.0.1-alpha.8

1 year ago

0.0.1-alpha.7

1 year ago

0.0.1-alpha.6

1 year ago

0.0.1-alpha.5

1 year ago

0.0.1-alpha.4

1 year ago

0.0.1-alpha.3

1 year ago

0.0.1-alpha.2

1 year ago

0.0.1-alpha.1

1 year ago