css-to-react-native-transform

1.0.8 • Public • Published

css-to-react-native-transform

NPM version Build Status Build status

A lightweight wrapper on top of css-to-react-native to allow valid CSS to be turned into React Native Stylesheet objects.

Example:

.myClass {
  font-size: 18px;
  line-height: 24px;
  color: red;
}

.other {
  padding: 1rem;
}

is transformed to:

{
  myClass: {
    fontSize: 18,
    lineHeight: 24,
    color: "red"
  },
  other: {
    paddingBottom: 16,
    paddingLeft: 16,
    paddingRight: 16,
    paddingTop: 16
  }
}

API

import transform from "css-to-react-native-transform";
// or const transform = require("css-to-react-native-transform").default;

transform(`
  .foo {
    color: #f00;
  }
`); // => { foo: { color: "#f00" } }

Limitations

  • For rem unit the root element font-size is currently set to 16 pixels. A setting needs to be implemented to allow the user to define the root element font-size.
  • There is also support for the box-shadow shorthand, and this converts into shadow- properties. Note that these only work on iOS.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.1.03,037latest

Version History

VersionDownloads (Last 7 Days)Published
2.1.03,037
2.0.0133
1.9.05,880
1.8.12
1.8.07
1.7.11
1.7.00
1.6.00
1.5.00
1.4.00
1.3.10
1.3.00
1.2.00
1.1.00
1.0.80
1.0.71
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i css-to-react-native-transform@1.0.8

Version

1.0.8

License

MIT

Unpacked Size

52.7 kB

Total Files

13

Last publish

Collaborators

  • kristerkari