tw= inline syntax not working as expected + styled-components/macro #185
-
Hey, When i use the inline syntax
This will work however if I import styled from 'styled-components/macro'. (I prefer the macro as it generates a classname based on the function name, also the non macro version does not work). Is there a way to override the default styled components of twin.macro to use the macro version? Best, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hey Adam I think you may be missing the About that styled macro import: I prefer the macro import too for the exact reasons you've mentioned. To specify the imports yourself, you'll just need to specify the imports in your twin config: Be sure to remove the // package.json
{
"babelMacros": {
"twin": {
"styled": {
"import": "default",
"from": "styled-components/macro"
},
"css": {
"import": "css",
"from": "styled-components/macro"
},
"global": {
"import": "createGlobalStyle",
"from": "styled-components"
},
}
},
}
// or babel-plugin-macros.config.js
module.exports = {
twin: {
styled: {
import: 'default',
from: 'styled-components/macro'
},
css: {
import: 'css',
from: 'styled-components/macro'
},
global: {
import: 'createGlobalStyle',
from: 'styled-components'
}
}
} |
Beta Was this translation helpful? Give feedback.
-
That works perfectly! Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hey Adam, in Twin v2 I now made that config the default so you can just roll with this config now: // package.json
{
"babelMacros": {
"twin": {
"preset": "styled-components",
}
},
}
// or babel-plugin-macros.config.js
module.exports = {
twin: {
preset: 'styled-components'
}
} |
Beta Was this translation helpful? Give feedback.
Hey Adam, in Twin v2 I now made that config the default so you can just roll with this config now: