stitchesjs / stitches

[Not Actively Maintained] CSS-in-JS with near-zero runtime, SSR, multi-variant support, and a best-in-class developer experience.

Home Page:https://stitches.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem `as` and `css` when used together.

s-kobets opened this issue · comments

Bug report

Describe the bug

Hi, I have problem when used as and css together.

To Reproduce

  1. I created component with stitches
const StyledTag = styled('span', {
  ...tw`
    border 
    border-current`,

  variants: {
    theme: {
      warning: tw`text-[#c5770f] bg-yellow-500`,
    },
  },
})

function Tag(props) {
  return <StyledTag {...props} />
}
  1. Render components
<>
    <Tag
      theme="warning"
      css={tw`text-red-500`}
    >
      Tag 1
    </Tag>
    <Tag
      as="div"
      theme="warning"
    >
      Tag 2
    </Tag>
    <Tag
      as="div"
      theme="warning"
      css={tw`text-red-500`}
    >
      Tag 3
    </Tag>
  </>
  1. See that Tag 3 don't get styles for theme warning

Expected behavior

I want to see that Tag 3 will be to the same Tag 1. Got styles for border and background

Screenshots

problem-screenshot

System information

  • OS: [macOS]
  • Browser (if applies) [chrome]
  • Version of Stitches: [1.2.8]
  • Version of Node.js: [16.16.0]

All work, I use twin.macro, tailwind, stitches. For stitches work all right.

I'm also seeing issues when using as and css together. It seems that if I use as, the css prop overwrites all of the styles instead of just the relevant style that it declares