0.3.5 • Published 2 years ago

react-native-css-modules v0.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.3.0-alpha.2

2 years ago

0.3.0-alpha.3

2 years ago

0.3.0-alpha.4

2 years ago

0.3.0-alpha.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago

0.0.3

2 years ago

0.1.1

2 years ago

0.0.2

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.0.4

2 years ago

0.0.1-alpha.15

2 years ago

0.0.1-alpha.14

3 years ago

0.0.1-alpha.13

3 years ago

0.0.1-alpha.12

3 years ago

0.0.1-alpha.11

3 years ago

0.0.1-alpha.10

3 years ago

0.0.1-alpha.9

3 years ago

0.0.1-alpha.8

3 years ago

0.0.1-alpha.7

3 years ago

0.0.1-alpha.6

3 years ago

0.0.1-alpha.5

3 years ago

0.0.1-alpha.4

3 years ago

0.0.1-alpha.3

3 years ago

0.0.1-alpha.2

3 years ago

0.0.1-alpha.1

3 years ago