question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`tw(...)` vs `tw([...])` resulting different class

See original GitHub issue

Please see this minimum example

import { tw } from "twind";

document.body.innerHTML = `
  <div class="${tw("bg-pink-50", "hover:text-pink-900", "p-3")}">
    Not array
  </div>

  <hr />

  <div class="${tw(["bg-pink-50", "hover:text-pink-900", "p-3"])}">
    Array
  </div>
`;

CodeSandbox

Screenshot

image

Everything behind hover: will be ignored when using tw(...)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
sastancommented, Dec 30, 2020

@rockmandash I don’t know where i got this from… I think some tweetet it:

directives: {
   tw: {
     inserted(el, binding) {
       el.className = tw`${binding.value}`
     },
   },
 },

// ------

<div v-tw="'h-screen bg-purple-400 flex items-center justify-center'">Awesome twind</div>

Maybe this helps with your project.

3reactions
sastancommented, Dec 30, 2020

It is now consistent with the array method:

tw('hover:bg-red-500', 'p-3')
tw(['hover:bg-red-500', 'p-3'])
// => hover:bg-red-500 p-3

If you want grouping to cross string boundaries you can use explicit grouping:

tw('hover:(', 'bg-red-500', 'p-3', ')', 'm-1')
// => hover:bg-red-500 hover:p-3 m-1

tw('hover:(bg-red-500', 'p-3)', 'm-1')
// => hover:bg-red-500 hover:p-3 m-1

tw({ hover: ['bg-red-500', 'p-3'] }, 'm-1')
// => hover:bg-red-500 hover:p-3 m-1
Read more comments on GitHub >

github_iconTop Results From Across the Web

T.W. v. School Board of Seminole County, Florida - Casetext
Wilson alleges that T.W. was subjected to physical and emotional abuse at the hands of Garrett, resulting in long-term emotional and psychological harm....
Read more >
Characterizing TW Hydra - IOPscience - Institute of Physics
We identify the best-fitting model by varying three stellar parameters: effective temperature, surface gravity, and magnetic field strength. We hold the values ...
Read more >
LIBSVM Tools
If k is the number of classes, we generate k(k-1)/2 models, each of which involves only two classes of training data. According to...
Read more >
Necrotizing soft tissue infections: Review and current concepts ...
Although not as widely accepted as a class of NSTI compared with types I and II, type III infections have been reported along...
Read more >
Immunoglobulin Structure and Classes - TW
Antibody (or immunoglobulin) molecules are glycoproteins composed of one or more ... Antibody classes differ in valency as a result of different numbers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found