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.

'css' is not exported from 'styled-components/macro'

See original GitHub issue

import css using twin.macro with styled-components fails. Below is the error when running local in my machine the cra-styled-component example. It works on codesandbox, but not local.

./src/components/Button.js
Attempted import error: 'css' is not exported from 'styled-components/macro' (imported as '_css').

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
ben-rogersoncommented, Dec 17, 2020

I’m seeing this too when I use yarn to install. npm works fine - I’ll have to look into this issue further.

You can fix it for now by using this twin config:

  "babelMacros": {
    "twin": {
      "preset": "styled-components",
      "css": {
        "from": "styled-components",
        "import": "css"
      }
    }
  },

Has babel updated something lately?

1reaction
jeremyzilarcommented, Jan 13, 2021

FYI, I just tried this with npm install and I got the same error

'css' is not exported from 'styled-components/macro'

So I cleared away the repo, and tried again using yarn and everything seems to work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

re export styled from styled components macro not working
I tried with export { css, createGlobalStyle, keyframes, ThemeProvider, withTheme, styled } . But without success. import React from 'react'; ...
Read more >
API Reference - styled-components
This is the default export. This is a low-level factory we use to create the styled.tagname helper methods. Arguments, Description ...
Read more >
FAQs - styled-components
In general, always use the css helper when composing styling partials to be interpolated into a styled component.. import styled, { keyframes } ......
Read more >
Tooling - styled-components
You may want to ensure that objects are consistently imported from the macro across your project. This can be achieved by using a...
Read more >
Releases - styled-components
Fixed the TS declarations not getting emitted correctly by rollup. ... Fix usage of the "css" prop with the styled-components babel macro (relevant...
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