linaria
linaria copied to clipboard
Add support for JS notation styles to styled API
Describe the feature
Currently the styled
API accepts literal tagged template literals which accepts CSS naming scheme for styles.
I think we could also extend the API to accept valid CSS styles in JavaScript notation too!
Motivation
- React Native devs would appreciate it.
- Some people like styling in JS way.
- More options for people to choose.
Possible implementations
Something similar to how emotion does,
const StyledHeading = styled('h1')(() => ({
fontSize: '24px'
});
props
or theme
from a ThemeProvider
can be passed to the callback function for easy access.
const StyledHeading = styled('h1')(({ theme, color }) => ({
fontSize: '24px',
...( color && { color })
});
Related Issues
It's possible, and I even made a PoC in @linaria/griffle, but it's not a priority right now. However, if someone makes a PR, I will be happy to merge it ;)