Skip to content

Why using "css" and not "style" for react components props (and is there a way to change that ?) #1152

Answered by hennessyevan
Aarbel asked this question in Help
Discussion options

You must be logged in to vote

Sure, there's 3 things at play here in this case. I've not used stitches with tailwind, but usually it goes like this:

Your button:

const Button = styled('button', {
  // ...
  
  variants: {
    tone: {
      filterActive: { },
      brandAccent: { }
    }
  }
})

Variants

This will create a few classes that are put into the head (trivialized here) so that if you switch variants at runtime you're just adding / removing class names which is pretty good for performance.

<style id="stitches">
  .button { ... }
  .button--tone-filterActive { ... }
  .button--tone-brandAccent { ... }
</style>

<button class="button" >...</button>

CSS Prop

But what if you really need a different appearance for …

Replies: 1 comment 2 replies

Comment options

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

@hennessyevan
Comment options

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