Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert React inline styles to CSS rules

Tags:

css

reactjs

Is there a tool, that converts React inline style descriptions to CSS rules?

Example input:

{
    minHeight: 200,
    position: 'relative',
    flexGrow: 1,
    flexShrink: 1,
    display: 'flex',
    flexDirection: 'column',
}

Example output:

{
    min-height: 200px;
    position: relative;
    flex-grow: 1;
    flex-shrink: 1;
    display: flex;
    flex-flow: column;
}

To put it differently, I want a tool that does the exact opposite of this: https://github.com/raphamorim/native-css

I would like to use it manually, so command line or web-based is preferable.

like image 731
sesm Avatar asked Jun 09 '18 10:06

sesm


2 Answers

Yes there's a tool that does just that!

https://glitch.com/~convert-css-js

If you paste your example input into the JS side (has to be in parentheses), you get the CSS output you specified (less the final semi-colon).

glitch convert css to js screenshot

like image 65
Ben Pritchard Avatar answered Oct 21 '22 12:10

Ben Pritchard


Have you tried this "A command line tool for JSS" https://github.com/cssinjs/cli

like image 44
karzan Avatar answered Oct 21 '22 12:10

karzan