[image-background problem] #605
-
import React, { Component } from 'react'
import tw, { styled } from 'twin.macro'
import Header from './components/Header'
const Wrapper = styled.div`
${
tw`
min-h-screen
bg-pattern-bg
`
}
`
export default class App extends Component {
render() {
return (
<Wrapper>
oi
<div className="bg-pattern-bg">
hi
</div>
<Header />
</Wrapper>
)
}
} Hello, I am learning how to use twin.macro and I ran into a problem that I am not able to solve. In the file tailwind.config.js, I created a background image called pattern-bg, but when I try to insert the background in "tw", the image doesn't appear on the screen. Now if I insert directly into the element just like it is in the code <div className = "bg-pattern-bg" ... the image works normally. If I try to use bg-[url('/src/images/pattern-bg.png')] in "tw" which is the image path, the following error appears:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey there Try one of these options: import tw from "twin.macro";
// Arbitrary value with lookup (tailwind feature)
tw`bg-[lookup:url('/src/images/pattern-bg.png')]`.backgroundImage
// Short css (twin feature)
tw`background-image[url('/src/images/pattern-bg.png')]` |
Beta Was this translation helpful? Give feedback.
Hey there
Try one of these options: