styled-addons

1.0.3Β β€’Β PublicΒ β€’Β Published

πŸ’… styled-addons

styled-components theming and more πŸ’… πŸ”₯

This library exists to make woroking with styled-components simpler.
Use theme variable names (or any other prop) and let styled-addons generate binding functions for you!

Read on Medium

Example

import styledProps from 'styled-addons'

const Button = styledProps ('button')`
    font-size: 15px;
    color: $theme.color;
    background: $theme.background;
`;

export default Button;

How to?

npm i --save styled-addons 
import styledProps from 'styled-addons'
import {ThemeProvider} from 'styled-components';

const Button = styledProps ('button')`
    font-size: 15px;
    color: $theme.color;
    background: $theme.background;
`;

const App = ({}) => {
	return (
		<ThemeProvider theme={{abc: 'red'}}>
			<Button>hey</Button>
		</ThemeProvider>
	)
}

How does it work ?

  • You write code like this
styledProps(...)`
  color: $theme.abc;
`
  • It gets transformed into this under the hood
styledProps(...)`
  color: ${props => props.theme.abc};
`

Contribute

It would be great to build a set of styled-components addons.
Fork and submit a PR or text me at vladislavzhabinsky@gmail.com

Package Sidebar

Install

npm i styled-addons

Weekly Downloads

6

Version

1.0.3

License

MIT

Unpacked Size

9.74 kB

Total Files

5

Last publish

Collaborators

  • zhabinsky