Gathering detailed insights and metrics for css-to-rn.macro
Gathering detailed insights and metrics for css-to-rn.macro
Gathering detailed insights and metrics for css-to-rn.macro
Gathering detailed insights and metrics for css-to-rn.macro
Convert CSS to React Native style sheet at build time with babel macros
npm install css-to-rn.macro
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
57 Stars
21 Commits
2 Forks
5 Watchers
21 Branches
2 Contributors
Updated on Nov 06, 2024
Latest Version
0.3.0
Package Id
css-to-rn.macro@0.3.0
Unpacked Size
122.75 kB
Size
34.44 kB
File Count
12
NPM Version
5.3.0
Node Version
8.6.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Convert CSS to React Native style sheet at build time with babel macros, using
css-to-react-native-transform
.
css
template literal like vscode-styled-components
1$ npm install --save-dev css-to-rn.macro
You'll also need to install and configure babel-plugin-macros
if you haven't already.
Input:
1import { StyleSheet } from 'react-native' 2import css from 'css-to-rn.macro' 3 4const styles = StyleSheet.create( 5 css` 6 .container { 7 flex: 1; 8 justify-content: center; 9 align-items: center; 10 } 11 `, 12)
Output:
1import { StyleSheet } from 'react-native' 2 3const styles = StyleSheet.create({ 4 container: { 5 flexGrow: 1, 6 flexShrink: 1, 7 flexBasis: 0, 8 justifyContent: 'center', 9 alignItems: 'center', 10 }, 11})
The css-to-react-native-transform
allow parsing the CSS Media Queries, and you can use it with react-native-css-media-query-processor
This is example for change styles with platform:
1import { StyleSheet } from 'react-native'
2import css, { parseMedia } from 'css-to-rn.macro'
3
4const styles = StyleSheet.create(
5 parseMedia(
6 css`
7 .container {
8 flex: 1;
9 justify-content: center;
10 align-items: center;
11 }
12 @media not android {
13 .container {
14 background-color: #ccc;
15 }
16 }
17 `,
18 {
19 /* match object of react-native-css-media-query-processor */
20 },
21 ),
22)
1const height = Math.random() * 100 2css` 3 .container { 4 height: ${height}; 5 } 6`
Due to the height
is random number, so it's unknown value at build time.
It will just fallback to css-to-react-native-transform
with a warning, but you can still use this macro.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/20 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
68 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More