Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are Glamor vs. Emotion's object syntax the same? #631

Closed
KyleAMathews opened this issue Apr 19, 2018 · 3 comments
Closed

Are Glamor vs. Emotion's object syntax the same? #631

KyleAMathews opened this issue Apr 19, 2018 · 3 comments

Comments

@KyleAMathews
Copy link

E.g. can I switch from using Glamor's css prop to Emotion's?

@emmatown
Copy link
Member

emmatown commented Apr 21, 2018

They're very similar, most projects will be able to switch without changing any styles. There are some slight differences, currently emotion doesn't support array fallbacks but I just opened #634 to address that and emotion doesn't stringify values for content like glamor does but I just opened #633 to warn in cases where glamor would stringify.

There are also some small differences in how the css prop works between glamor and emotion. Firstly, emotion's css prop currently works by transforming the css prop to a className prop in a babel plugin so spreading an object with a css key doesn't work. This is likely going to change soon, you can see what it's probably going to look like in https://github.com/emotion-js/next. The other difference is that emotion classNames passed take precedence over the styles passed to the css prop, this is so that you can override a components styles by using the css prop with it. For example, the example below is hotpink in emotion and green in glamor

const SomeComponent = ({ className }) => (
  <div css={{ color: "green" }} className={className} />
);

render(<SomeComponent css={{ color: "hotpink" }} />);

@tkh44
Copy link
Member

tkh44 commented Apr 23, 2018

Closed in #633. If you have any more questions @KyleAMathews lmk.

@KyleAMathews
Copy link
Author

Thanks for the detailed response! Looks like it'd pretty easy to switch.

@emmatown emmatown closed this as completed May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants