Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Using conditional tailwind classes for twin.macro

import tw from 'twin.macro'

const Component = ({ hasBg }) => (
  <div
    css={[
      tw`flex w-full`, // Add base styles first
      hasBg && tw`bg-black`, // Then add conditional styles
    ]}
  >
    <div tw="w-1/2" />
    <div tw="w-1/2" />
  </div>
)
Source by github.com #
 
PREVIOUS NEXT
Tagged: #Using #conditional #tailwind #classes
ADD COMMENT
Topic
Name
6+7 =