Skip to content

using css and tw on react components #258

Closed Answered by ben-rogerson
saeedPadyab asked this question in General
Discussion options

You must be logged in to vote

Just tested with preset="styled-components" and all seems okay, I was wondering if you were testing with light colors which made it hard to tell if they change?

Here's my test:

import React from 'react'
import tw, { styled } from 'twin.macro'

export const Input = styled.input`
  ${tw`bg-green-500`};
`

const InputGroup = (props) => {
  return <Input {...props} />
}

const App = () => (
  <>
    <InputGroup />
    <InputGroup tw="bg-blue-500" />
    <InputGroup css={[tw`bg-yellow-500`]} />
  </>
)

export default App

And the output:

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@saeedPadyab
Comment options

Comment options

You must be logged in to vote
2 replies
@saeedPadyab
Comment options

@ben-rogerson
Comment options

Answer selected by ben-rogerson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants