react-get-styles

Helper to get object with styles from string or template string

Usage no npm install needed!

<script type="module">
  import reactGetStyles from 'https://cdn.skypack.dev/react-get-styles';
</script>

README

React Get Styles

Build Status

Help you to get object with styles from string or template string such as:

// Input
const styles = gm`
  border-radius: 3px;
  flex-direction: column;
  box-shadow: 3px 1px 10px rgba(0,0,0,0.3); 
`
// Output
const styles = {
   borderRadius: '3px',
   flexDirection: 'column'
   boxShadow: '3px 1px 10px rgba(0,0,0,0.3)'
 }

Usage

npm install react-get-styles


import gs from 'react-get-styles'

const titleStyles = gs`
  border-radius: 3px;
  flex-direction: column;
  box-shadow: 3px 1px 10px rgba(0,0,0,0.3);
`

const Title = ({ text }) => (
  <h1 styles={titleStyles}>
    { text }
  </h1>
)


This component uses Standard JS

JavaScript Style Guide