goober icon indicating copy to clipboard operation
goober copied to clipboard

Support interpolated objects

Open ben-rogerson opened this issue 3 years ago • 2 comments

Hey Cristian

Would it be possible to add support for objects interpolated within template literals?

const Component = styled("div")`

  /* An interpolated style object (unsupported) */
  ${{ display: "block" }};

  /* An interpolated function returning a style object (supported) */
  ${() => ({ display: "block" })};

`

This feature would be great so people using twin can add styles like this:

const Component = styled("div")`
  ${tw`block`};
  background-color: red;
`

ben-rogerson avatar Apr 14 '21 02:04 ben-rogerson

Hi @ben-rogerson!

Actually that's a good point! I think we've played with this before 😅 and also recently I had a discussion about not being able to spread the props on tagged templates. With that being said, gonna add the support for this, asap.

cristianbote avatar Apr 14 '21 06:04 cristianbote

That's awesome, thanks Christian 👍

The prop spreading would be a great feature too.

ben-rogerson avatar Apr 16 '21 23:04 ben-rogerson