question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
lee-reinhardtcommented, Mar 19, 2019

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.

0reactions
tomitrescakcommented, Dec 13, 2019

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The css Prop - Emotion
css from @emotion/react does not return the computed class name string. The function returns an object containing the computed name and flattened styles....
Read more >
Why you shouldn't use @emotion/core - Colin McDonnell
Emotion recommends using their non-standard css prop to style your components, instead of React's built-in className . This causes me ...
Read more >
Emotion 10: CSS-in-JS with Flexible Scoped and Global ...
Class names containing Emotion styles from the className prop override css prop styles. Class names from sources other than Emotion are ignored ...
Read more >
@emotion/react | Yarn - Package Manager
Install. yarn add @emotion/react. Usage. /** @jsx jsx */ import { jsx, css, Global, ClassNames } from '@emotion/react' render( <div css={{ color: 'hotpink'...
Read more >
npm:react-classed | Skypack
Create React components with CSS classes. ... You can pass an array of classnames and allow any type of other input:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found