Emotion: Allowing `css({})` for creating className strings in @emotion/core

Created on 15 Mar 2019  路  5Comments  路  Source: emotion-js/emotion

First of, Emotion is awesome, and open-source is hard, great work!

This question might have been asked, but I was wondering if the behavior of css({ }) to generate a class name is still possible in @emotion/core?

What I want

import { css } from '@emotion/core';

<div className={css({ background: 'red' })} />

Suggested solution:

Maybe use css({ }).className?

I know that ClassNames is exported, but this seems quite annoying to use as a render prop. If that's the way to go, any chance we could export ClassNames.css and ClassNames.cx as static methods?

Most helpful comment

I believe the "css() generates/returns a class name" functionality is in the framework-agnostic emotion package as of v10.

See:

If you were asking for this to be _specifically_ added in @emotion/core, then carry on; but the re-org of the packages was a little unclear at first. However, I think the intro docs explain the goal of each package very well now.

All 5 comments

I believe the "css() generates/returns a class name" functionality is in the framework-agnostic emotion package as of v10.

See:

If you were asking for this to be _specifically_ added in @emotion/core, then carry on; but the re-org of the packages was a little unclear at first. However, I think the intro docs explain the goal of each package very well now.

Thanks @lee-reinhardt!

If I import @emotion/core and emotion as well will not that duplicate the size ?

Not by that much as you could have expect because a good chunk of of the code is shared between those packages

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lewisl9029 picture lewisl9029  路  33Comments

ehahn9 picture ehahn9  路  22Comments

mitchellhamilton picture mitchellhamilton  路  82Comments

eXtreaL picture eXtreaL  路  29Comments

Andarist picture Andarist  路  54Comments